This commit is contained in:
2023-10-23 13:23:36 +02:00
parent 667dae6f1a
commit 322b22f9bf
5711 changed files with 72953 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
public class Compteur {
private int compte;
public Compteur() {
this.compte = 0;
}
public int getValue(){
return this.compte;
}
public Compteur(int value) {
this.compte = value;
}
public void plusUn() {
this.compte++;
}
public String toString() {
return Integer.toBinaryString(this.compte);
}
}

Binary file not shown.

View File

@@ -0,0 +1,51 @@
public class Date{
protected int annee;
protected int mois;
protected int jour;
protected static int[] jourDuMois = {31,28,31,30,31,30,31,31,30,31,30,31};
public Date(int annee, int mois, int jour){
this.annee = annee;
this.mois = mois;
this.jour = jour;
}
public String toString(){
String stringAnnee = add0(this.annee, 4);
String stringMois = add0(this.mois, 2);
String stringJour = add0(this.jour, 2);
return stringAnnee + "-" + stringMois + "-" + stringJour;
}
public void lendemain(){
this.jour ++;
if (this.jour > Date.jourDuMois[this.mois-1]){
this.jour = 1;
this.mois ++;
if (this.mois > 12){
this.mois = 1;
this.annee ++;
}
}
}
public boolean compare(Date date){
if (this.annee == date.annee && this.mois == date.mois && this.jour == date.jour){
return true;
}
return false;
}
private static String add0(int nombre, int taille){
int puissance10 = 1;
String resultat = Integer.toString(nombre);
for (int i=1; i<taille ; i++){
puissance10 *= 10;
}
while (nombre<puissance10){
resultat = "0" + resultat;
nombre *= 10;
}
return resultat;
}
}

View File

@@ -0,0 +1,51 @@
public class Date{
private int annee;
private int mois;
private int jour;
private static int[] jourDuMois = {31,28,31,30,31,30,31,31,30,31,30,31};
public Date(int annee, int mois, int jour){
this.annee = annee;
this.mois = mois;
this.jour = jour;
}
public String toString(){
String stringAnnee = add0(this.annee, 4);
String stringMois = add0(this.mois, 2);
String stringJour = add0(this.jour, 2);
return stringAnnee + "-" + stringMois + "-" + stringJour;
}
public void lendemain(){
this.jour ++;
if (this.jour > Date.jourDuMois[this.mois-1]){
this.jour = 1;
this.mois ++;
if (this.mois > 12){
this.mois = 1;
this.annee ++;
}
}
}
public boolean compare(Date date){
if (this.annee == date.annee && this.mois == date.mois && this.jour == date.jour){
return true;
}
return false;
}
public static String add0(int nombre, int taille){
int puissance10 = 1;
String resultat = Integer.toString(nombre);
for (int i=1; i<taille ; i++){
puissance10 *= 10;
}
while (nombre<puissance10){
resultat = "0" + resultat;
nombre *= 10;
}
return resultat;
}
}

View File

@@ -0,0 +1,9 @@
public class Q1_Progression {
public static void main(String[] args) {
Compteur c = new Compteur(5);
do {
System.out.println(c.toString());
c.plusUn();
} while (c.getValue() <=9);
}
}

View File

@@ -0,0 +1,9 @@
public class Q1_Progression {
public static void main(String[] args) {
Compteur c = new Compteur(5);
do {
System.out.println(c.toString());
c.plusUn();
} while (c.getValue() <=9);
}
}

Binary file not shown.

View File

@@ -0,0 +1,14 @@
public class Q2_Date {
public static void main(String[] args) {
Date today = new Date(2023, 2, 23);
Date mariage = new Date(2023, 3, 1);
for (int i=0; i<10 ; i++){
System.out.print(today);
if (today.compare(mariage)){
System.out.print(" = Jour de mariage !!!");
}
System.out.println("");
today.lendemain();
}
}
}

View File

@@ -0,0 +1,14 @@
public class Q2_Date {
public static void main(String[] args) {
Date jourRandom = new Date(2023, 2, 23);
Date mariage = new Date(2023, 3, 1);
for (int i=0; i<10 ; i++){
System.out.print(jourRandom);
if (jourRandom.compare(mariage)){
System.out.print(" = Jour de mariage !!!");
}
System.out.println("");
jourRandom.lendemain();
}
}
}

View File

@@ -0,0 +1,35 @@
public class Periode extends Date{
protected int interval;
protected int anneeFin;
protected int moisFin;
protected int jourFin;
public Periode(int anneeDebut, int moisDebut, int jourDebut, int anneeFin, int moisFin, int jourFin){
super(anneeDebut, moisDebut, jourDebut);
this.anneeFin = anneeFin;
this.moisFin = moisFin;
this.jourFin = jourFin;
this.interval = compteurJour();
}
public int compteurJour(){
int compteur = 0;
compteur += this.anneeFin*365;
for (i=0 ; i<this.moisFin ; i++){
compteur += this.jourDuMois[i];
}
compteur += this.jourFin;
compteur -= this.anneeDebut*365;
for (i=0 ; i<this.moisDebut ; i++){
compteur -= this.jourDuMois[i];
}
compteur -= this.jourDebut;
return compteur;
}
public void(){
this.lendemain
}
}