This commit is contained in:
Vieira Enzo 2022-02-08 15:59:04 +01:00
parent 04d989559e
commit 67ab03f916
15 changed files with 181 additions and 17 deletions

Binary file not shown.

View File

@ -3,19 +3,34 @@ import java.awt.*;
public class Question { public class Question {
public static void main(String[] args) { public static void main(String[] args) {
JFrame fenetre = new JFrame();
Color vert = new Color(0,255,0);
Color noir = new Color(0,0,0);
JFrame fenetre = new JFrame("Question");
fenetre.setSize(500, 300); fenetre.setSize(500, 300);
fenetre.setMinimumSize(new Dimension(300, 200)); fenetre.setLocation(0, 0);
GridLayout gestionnaire = new GridLayout(3,3); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setLayout(gestionnaire); Dimension minSize = new Dimension(300, 150);
JPanel panneau = new JPanel(); fenetre.setMinimumSize(minSize);
JButton bouton = new JButton("Oui"); FlowLayout flwLayout = new FlowLayout();
panneau.add(bouton); GridLayout grdLayout = new GridLayout(4, 1);
JButton bouton2 = new JButton("Non"); fenetre.setLayout(grdLayout);
panneau.add(bouton2); JLabel question = new JLabel("Aimez-vous les chiens ?");
JButton bouton3 = new JButton("NSPP"); question.setHorizontalAlignment(JLabel.CENTER);
panneau.add(bouton3); JPanel boutons = new JPanel();
fenetre.add(panneau); boutons.setLayout(flwLayout);
JButton bouton1 = new JButton("Oui");
JButton bouton2 = new JButton("NSPP");
JButton bouton3 = new JButton("Non");
boutons.add(bouton1);
boutons.add(bouton2);
boutons.add(bouton3);
fenetre.add(new JLabel(""));
fenetre.add(question);
fenetre.add(boutons);
fenetre.add(new JLabel(""));
fenetre.setVisible(true); fenetre.setVisible(true);
} }
} }

0
APL2.1/TP3/Rose.java Normal file
View File

BIN
APL2.1/TP4/Date/Date.class Normal file

Binary file not shown.

44
APL2.1/TP4/Date/Date.java Normal file
View File

@ -0,0 +1,44 @@
public class Date {
private int year;
private int month;
private int day;
public Date(int d, int m, int y) {
this.year = y;
this.month = m;
this.day = d;
}
public int Day() {
return this.day;
}
public int Month() {
return this.month;
}
public int Year() {
return this.year;
}
public String toString() {
int i;
String sday = Integer.toString(this.day);
String smonth = Integer.toString(this.month);
String syear = Integer.toString(this.year);
if (sday.length() < 2) {
for (i = 0; i<2-sday.length(); i++) {
sday = "0"+sday;
}
}
if (smonth.length() < 2) {
for (i = 0; i<2-smonth.length(); i++) {
smonth = "0"+smonth;
}
}
if (syear.length() < 4) {
for (i = 0; i<4-syear.length(); i++) {
syear = "0"+syear;
}
}
return syear+"-"+smonth+"-"+sday;
}
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
public class Testdate {
public static void main(String[] args) {
Date date = new Date(8,2,2022);
Date date2 = new Date(31, 1, 2022);
System.out.println("Date du jour : " + date);
}
}

Binary file not shown.

View File

@ -0,0 +1,62 @@
public class Date {
private int year;
private int month;
private int day;
public Date(int d, int m, int y) {
this.year = y;
this.month = m;
this.day = d;
}
public int Day() {
return this.day;
}
public int Month() {
return this.month;
}
public int Year() {
return this.year;
}
public void Lendemain() {
int monthinyear = 12;
int[] dayinmonth = {31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
if (this.day == dayinmonth[this.month-1]) {
this.day = 1;
this.month += 1;
if (this.month > monthinyear) {
this.month = 1;
this.year +=1;
}
} else {
this.day += 1;
}
}
public String toString() {
int i;
String sday = Integer.toString(this.day);
String smonth = Integer.toString(this.month);
String syear = Integer.toString(this.year);
if (sday.length() < 2) {
for (i = 0; i<2-sday.length(); i++) {
sday = "0"+sday;
}
}
if (smonth.length() < 2) {
for (i = 0; i<2-smonth.length(); i++) {
smonth = "0"+smonth;
}
}
if (syear.length() < 4) {
for (i = 0; i<4-syear.length(); i++) {
syear = "0"+syear;
}
}
return syear+"-"+smonth+"-"+sday;
}
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
public class Lendemain {
public static void main(String[] args) {
Date date = new Date(8,2,2022);
System.out.println("Date du jour : " + date);
date.Lendemain();
System.out.println("Date du lendemain : " + date);
}
}

Binary file not shown.

View File

@ -0,0 +1,18 @@
public class Compteur {
private int compte;
public Compteur() {
this.compte = 0;
}
public Compteur(int h) {
this.compte = h;
}
// méthode
public void plusUn() {
this.compte++;
}
// autre méthode
public String toString() {
return Integer.toBinaryString(this.compte);
}
}

Binary file not shown.

View File

@ -0,0 +1,9 @@
public class Progression {
public static void main(String[] args) {
Compteur c = new Compteur(5);
for (int i=0;i<5;i++){
System.out.println(c);
c.plusUn();
}
}
}