public class Date {

private int _day;
private int _month;
private int _year;
boolean checkDate=true;
public Date(int day,int month,int year) {
if ((day>31)||(day<1)) {
System.out.println("You entered a wrong day");
checkDate=false;}
else if ((month>12)||(month<1)) {
system.out.println("You entered a wrong month");
checkDate=false;}
if (checkDate=true) {
_day=day;
_month=month;
_year=year;  
}
}

public Date()  {
_day=3;
_month=1;
_year=2009; }

public int getDay {
return _day;
    }
public int getMonth {
return _month;
    }
public int getYear {
return _year;
        }
public StringtoString{
String str= "";
str+="day:"+getDay()+"  ";
str+="month:"+getMonth()+"  ";
str+="year:"+getYear()+"  ";
return str;
}
}

Hey, maybe someone one can help me?
I've got an error message from the compiler " ';' expected".

I'm very new in this, so i don't know what to do.
Thanks for any kind of help. :S

Use code tags.

system.out.println("You entered a wrong month");
Should say: [B]S[/B]ystem.out.println ....

And in at least one spot that I noticed, you're using "=" to compare things, when you should be using "==". One equals is used for assignment (to set day = today; for example), two equals are used for comparison, does today == tomorrow for example.

Also, copy and paste the full compiler error to us, so that we can help you better. I don't see anywhere where you're missing a ';'. It could be because of your other errors, though, so fix those first.

start quote:

public class Date {

private int _day;
private int _month;
private int _year;
boolean checkDate=true;
public Date(int day,int month,int year) {
if ((day>31)||(day<1)) {
System.out.println("You entered a wrong day");
checkDate=false;}
else if ((month>12)||(month<1)) {
system.out.println("You entered a wrong month");
checkDate=false;}
if (checkDate=true) {
_day=day;
_month=month;
_year=year;  
}
}

public Date()  {
_day=3;
_month=1;
_year=2009; }

public int getDay {
return _day;
    }
public int getMonth {
return _month;
    }
public int getYear {
return _year;
        }
public StringtoString{
String str= "";
str+="day:"+getDay()+"  ";
str+="month:"+getMonth()+"  ";
str+="year:"+getYear()+"  ";
return str;
}
}

Hey, maybe someone one can help me?
I've got an error message from the compiler ';' expected.

I'm very new in this, so i don't know what to do.
Thanks for any kind of help. :S

Code tags please:

// paste code here

The compiler will give you a line number with the error. Please point it out in the code (code tags will add line numbers).

Edit: BestJewSinceJC beat me to it.

Ok, i fixed the first problem, but now i've got another one.

Here are my two classes:

public class Item
{
protected String _name;
private static long _catalogueNumber=1000001;
protected int _quantity;

public Item (String name, int quantity)
{
_name=name;
_quantity=quantity;
_catalogueNumber+=1;
}

public String getName()
{
return _name;
}

public int getQuantity()
{
return _quantity;
}

public long getCatalogueNumber() 
{
return _catalogueNumber;
}
}

And the second class:

public class FoodItem  extends Item {
protected String _productionDate;
protected String _expiryDate;
public FoodItem ( String name, String ProductionDate, String expiryDate){
super (name);
 _productionDate= productionDate;
 _expiryDate=expiryDate;
}
public String getProductionDate(){
return _productionDate;
}
public String getExpiryDate(){
return _expiryDate;
}

public String toString(){
 String str = "";
        str += "name: " +getName()+ "   ";
        str += "production date: " +  getProductionDate() + "   ";
        str += "expiry date: " +  getExpiryDate() + "   ";
        return str;
    }
}

And i get the error message "cannot find symbol-constructor Item(java.lang.String)", and the super(name); line is marked.

What seems to be the problem?

Ok, i fixed the first problem, but now i've got another one.

Here are my two classes:

public class Item
{
protected String _name;
private static long _catalogueNumber=1000001;
protected int _quantity;

public Item (String name, int quantity)
{
_name=name;
_quantity=quantity;
_catalogueNumber+=1;
}

public String getName()
{
return _name;
}

public int getQuantity()
{
return _quantity;
}

public long getCatalogueNumber() 
{
return _catalogueNumber;
}
}

And the second class:

public class FoodItem  extends Item {
protected String _productionDate;
protected String _expiryDate;
public FoodItem ( String name, String ProductionDate, String expiryDate){
super (name);
 _productionDate= productionDate;
 _expiryDate=expiryDate;
}
public String getProductionDate(){
return _productionDate;
}
public String getExpiryDate(){
return _expiryDate;
}

public String toString(){
 String str = "";
        str += "name: " +getName()+ "   ";
        str += "production date: " +  getProductionDate() + "   ";
        str += "expiry date: " +  getExpiryDate() + "   ";
        return str;
    }
}

And i get the error message "cannot find symbol-constructor Item(java.lang.String)", and the super(name); line is marked.

What seems to be the problem?

Line 14:

super (name);

The superclass of FoodItem is Item . name is of type String . This line says the following:

Find the constructor in the Item class that takes a single String argument and pass it name and execute it.

No such constructor exists in Item . You have one constructor there and it takes two parameters, not one. So Java has no idea what you are trying to do with this command since nothing matches.

Thank you!

I hava one last problem. When i try to compile this class:

public class RefrigiratedItem  extends Item {
private int _minTemperature;
private int _maxTemperature;
public RefrigiratedItem ( String name, int minTemperature, int maxTemperature, int quantity){
super (name, quantity) ;
 _ minTemperature= minTemperature;
 _maxTemperature= maxTemperature;
}
public int getMinTemp(){
return _minTemperature;
}
public int getMaxTemp(){
return _maxTemperature;
}

public String toString(){
 String str = "";
        str += "name: " +getName()+ "   ";
        str += "min temperature: " +  getMinTemp() + "   ";
        str += "max temperature: " +  getMaxTemp() + "   ";
        str += "quantity: " +  getQuantity() + "   ";
        return str;
    }
}

I get the error message "cannot find symbol-class_", and the" _ minTemperature= minTemperature;" is marked.
What can be the problem?

This error caused by whitespace between '_' and 'minTemperature' here:

_ minTemperature= minTemperature;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.