Hi
please tell me the wrong in this code becaus it not compile with me
the question depend in other class that i do it before
and this class her:
public class GField
{
private int value;
private int minimum;
private int maximum;
private int defu;
public GField(int v,int m,int x,int def){
if (v>minimum && v<maximum) value=v;
else value=1;
value = v; minimum= m; maximum =x;
defu=def;
}
public int getV(){
return value;}
public int getM(){
return minimum;}
public int getX(){
return maximum;}
public void setV( int v){
if (v>minimum && v<maximum) value=v;
else value=1;
value = v;
}
public void setM( int m)
{
minimum= m;}
public void setX( int x)
{
maximum= x;}
but the other question is
2- Date class: this class has day, month, and year fields. All fields must be defined privates and all fields are of type GField defined above.
a. Provide a default constructor in which you set the date to 1/1/2000.
b. Provide a constructor that takes 3 integer parameters for the 3 fields.
c. Provide a constructor that takes 2 integer parameters for the day and month. The constructor should set the year to 2007.
d. Provide only getters for each field.
e. Provide the toString method such that it returns a string representation of the date in the form DD/Month/YYYY, e.g, (12/November/1990)
f. Write a method that returns the name of the month. For example, if the month is 3 it will returns "march".
g. Make sure that each field holds correct values. Specifically, month should be between 1 and 12 and day should be between 1 and 31. In case the user provided invalid day or month then you need to save a valid value instead as follows:
i. If the user provides a month which is not between 1 and 12, then set it with |(N % 12) + 1|.
ii. For days, if the user provides a day which is not between 1 and 31 then set it with the value | (N % 31) + 1|.
and i try to do it but it is not compile please tell me the wrong and this cod i wrote it.
public class Date1
{
private GField day;
private GField month;
private GField year;
public Date1(){
day=1;
month=1;
year=2000;
}
public Date1 ( GField D, GField M, GField Y){
if(M<=12 && M>=1) month=M;
else m=abs((N % 12) + 1) ;
if (D>=1 && D<=31) day=D;
else day=abs ((N % 31) + 1);
;
year= Y;
}
Date1( GField D, GField M){
day= D;
month=M;
year=2007;
}
GField getDay(){
return day;
}
GField getMonth(){
return month;
}
GField getYear(){
return year;
}
public String toString(){
return day + "/" + month + "/" + year;
}
public String getName(){
if (m==1) return "Jan";
if (m==2) return "november";
if (m==3) return " march";
if (m==4) return "Apr";
if (m==5) return "May";
if (m==6) return "JUN";
if (m==7) return "july";
if (m==8) return "Augest.";
if (m==9) return "Septemr";
if (m==10) return "october";
if (m==11) return "Nov";
else return "DEC";
}
}
Sorry if the question is too long and i hope who know the question explen to me the step of do this question