public class CFecha {
//ATRIBUTOS
int Dia;
int Mes;
int Año;
//CONSTRUCTORES
public CFecha(int pdia, int pmes, int paño){
Dia=pdia;
Mes=pmes;
Año=paño;
}
//MODIFICADORES
public void setDia(int pdia){
Dia=pdia;
}
public void setMes(int pmes){
Mes=pmes;
}
public void setAño(int paño){
Año=paño;
}
//ACCEDENTES
public int getDia(){
return Dia;
}
public int getMes(){
return Mes;
}
public int getAño(){
return Año;
}
//OTROS MÉTODOS
public CFecha FechaMayor(CFecha fecha)
{
int Dia1=fecha.getDia();
int Mes1=fecha.getMes();
int Año1=fecha.getAño();
if(Año>Año1)
return this;
else
if(Año<Año1)
return fecha;
else
if(Año==Año1)
{
if(Mes>Mes1)
return this;
else
if(Mes<Mes1)
return fecha;
else
if(Dia>Dia1)
return this;
else
return fecha;
}
return null;
}
public void EscribeFecha(){
System.out.println("La fecha mayor es: "+Dia +"/"+ Mes+"/"+ Año);
}
}
How can I show how many days have that month (if I have a date in the main class, I want to know how many)?