Ajout des travaux effectuer
This commit is contained in:
BIN
23DEV1.1/TPS2/TP01/ClassesEtObjets/Compteur.class
Normal file
BIN
23DEV1.1/TPS2/TP01/ClassesEtObjets/Compteur.class
Normal file
Binary file not shown.
21
23DEV1.1/TPS2/TP01/ClassesEtObjets/Compteur.java
Normal file
21
23DEV1.1/TPS2/TP01/ClassesEtObjets/Compteur.java
Normal file
@@ -0,0 +1,21 @@
|
||||
public class Compteur {
|
||||
|
||||
private int compte;
|
||||
|
||||
public void plusUn()
|
||||
{
|
||||
this.compte++;
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
return Integer.toBinaryString(this.compte);
|
||||
}
|
||||
public Compteur()
|
||||
{
|
||||
this.compte = 5;
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println(toString());
|
||||
}
|
||||
}
|
||||
BIN
23DEV1.1/TPS2/TP01/ClassesEtObjets/Date.class
Normal file
BIN
23DEV1.1/TPS2/TP01/ClassesEtObjets/Date.class
Normal file
Binary file not shown.
65
23DEV1.1/TPS2/TP01/ClassesEtObjets/Date.java
Normal file
65
23DEV1.1/TPS2/TP01/ClassesEtObjets/Date.java
Normal file
@@ -0,0 +1,65 @@
|
||||
public class Date {
|
||||
|
||||
private int year;
|
||||
private int month;
|
||||
private int day;
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String Date = String.format("%04d-%02d-%02d", this.year, this.month, this.day);
|
||||
return Date;
|
||||
}
|
||||
public void Lendemain()
|
||||
{
|
||||
if(this.month == 1 || this.month == 3 || this.month == 5 || this.month == 7 || this.month == 8 || this.month == 10)
|
||||
{
|
||||
if(this.day == 31)
|
||||
{
|
||||
this.day = 1;
|
||||
this.month++;
|
||||
}
|
||||
}
|
||||
if(this.month == 2)
|
||||
{
|
||||
if(this.day == 28)
|
||||
{
|
||||
this.day = 1;
|
||||
this.month++;
|
||||
}
|
||||
}
|
||||
if(this.month == 4 || this.month == 6 || this.month == 9 || this.month == 11)
|
||||
{
|
||||
if(this.day == 30)
|
||||
{
|
||||
this.day = 1;
|
||||
this.month++;
|
||||
}
|
||||
}
|
||||
if(this.month == 12)
|
||||
{
|
||||
if(this.day == 31)
|
||||
{
|
||||
this.day = 1;
|
||||
this.month = 1;
|
||||
this.year++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.day++;
|
||||
}
|
||||
}
|
||||
public Date()
|
||||
{
|
||||
this.year = 2024;
|
||||
this.month = 02;
|
||||
this.day = 6;
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Date c = new Date();
|
||||
System.out.println(c);
|
||||
c.Lendemain();
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user