diff --git a/APL2.1/TP3/Question.class b/APL2.1/TP3/Question.class index 4377924..6c58ed2 100644 Binary files a/APL2.1/TP3/Question.class and b/APL2.1/TP3/Question.class differ diff --git a/APL2.1/TP3/Question.java b/APL2.1/TP3/Question.java index 590d566..c979f46 100644 --- a/APL2.1/TP3/Question.java +++ b/APL2.1/TP3/Question.java @@ -2,20 +2,35 @@ import javax.swing.*; import java.awt.*; public class Question { - public static void main(String[] args) { - JFrame fenetre = new JFrame(); - fenetre.setSize(500,300); - fenetre.setMinimumSize(new Dimension(300, 200)); - GridLayout gestionnaire = new GridLayout(3,3); - fenetre.setLayout(gestionnaire); - JPanel panneau = new JPanel(); - JButton bouton = new JButton("Oui"); - panneau.add(bouton); - JButton bouton2 = new JButton("Non"); - panneau.add(bouton2); - JButton bouton3 = new JButton("NSPP"); - panneau.add(bouton3); - fenetre.add(panneau); - fenetre.setVisible(true); - } -} + public static void main(String[] args) { + + Color vert = new Color(0,255,0); + Color noir = new Color(0,0,0); + JFrame fenetre = new JFrame("Question"); + fenetre.setSize(500, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Dimension minSize = new Dimension(300, 150); + fenetre.setMinimumSize(minSize); + FlowLayout flwLayout = new FlowLayout(); + GridLayout grdLayout = new GridLayout(4, 1); + fenetre.setLayout(grdLayout); + JLabel question = new JLabel("Aimez-vous les chiens ?"); + question.setHorizontalAlignment(JLabel.CENTER); + JPanel boutons = new JPanel(); + 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); + + + } +} \ No newline at end of file diff --git a/APL2.1/TP3/Rose.java b/APL2.1/TP3/Rose.java new file mode 100644 index 0000000..e69de29 diff --git a/APL2.1/TP4/Date/Date.class b/APL2.1/TP4/Date/Date.class new file mode 100644 index 0000000..be063eb Binary files /dev/null and b/APL2.1/TP4/Date/Date.class differ diff --git a/APL2.1/TP4/Date/Date.java b/APL2.1/TP4/Date/Date.java new file mode 100644 index 0000000..2423796 --- /dev/null +++ b/APL2.1/TP4/Date/Date.java @@ -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; + } +} \ No newline at end of file diff --git a/APL2.1/TP4/Date/Testdate.class b/APL2.1/TP4/Date/Testdate.class new file mode 100644 index 0000000..578e285 Binary files /dev/null and b/APL2.1/TP4/Date/Testdate.class differ diff --git a/APL2.1/TP4/Date/Testdate.java b/APL2.1/TP4/Date/Testdate.java new file mode 100644 index 0000000..41ca44b --- /dev/null +++ b/APL2.1/TP4/Date/Testdate.java @@ -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); + } +} \ No newline at end of file diff --git a/APL2.1/TP4/Lendemain/Date.class b/APL2.1/TP4/Lendemain/Date.class new file mode 100644 index 0000000..d1fee79 Binary files /dev/null and b/APL2.1/TP4/Lendemain/Date.class differ diff --git a/APL2.1/TP4/Lendemain/Date.java b/APL2.1/TP4/Lendemain/Date.java new file mode 100644 index 0000000..8f6bd81 --- /dev/null +++ b/APL2.1/TP4/Lendemain/Date.java @@ -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; + } +} \ No newline at end of file diff --git a/APL2.1/TP4/Lendemain/Lendemain.class b/APL2.1/TP4/Lendemain/Lendemain.class new file mode 100644 index 0000000..37b5b75 Binary files /dev/null and b/APL2.1/TP4/Lendemain/Lendemain.class differ diff --git a/APL2.1/TP4/Lendemain/Lendemain.java b/APL2.1/TP4/Lendemain/Lendemain.java new file mode 100644 index 0000000..4faa48b --- /dev/null +++ b/APL2.1/TP4/Lendemain/Lendemain.java @@ -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); + } +} \ No newline at end of file diff --git a/APL2.1/TP4/Progression/Compteur.class b/APL2.1/TP4/Progression/Compteur.class new file mode 100644 index 0000000..69a930b Binary files /dev/null and b/APL2.1/TP4/Progression/Compteur.class differ diff --git a/APL2.1/TP4/Progression/Compteur.java b/APL2.1/TP4/Progression/Compteur.java new file mode 100644 index 0000000..4e7e186 --- /dev/null +++ b/APL2.1/TP4/Progression/Compteur.java @@ -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); + } + +} \ No newline at end of file diff --git a/APL2.1/TP4/Progression/Progression.class b/APL2.1/TP4/Progression/Progression.class new file mode 100644 index 0000000..8c91bd6 Binary files /dev/null and b/APL2.1/TP4/Progression/Progression.class differ diff --git a/APL2.1/TP4/Progression/Progression.java b/APL2.1/TP4/Progression/Progression.java new file mode 100644 index 0000000..07e3948 --- /dev/null +++ b/APL2.1/TP4/Progression/Progression.java @@ -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(); + } + } +} \ No newline at end of file