diff --git a/APL2.1/TP01/Arguments/Arguments.class b/APL2.1/TP01/Arguments/Arguments.class new file mode 100644 index 0000000..c997241 Binary files /dev/null and b/APL2.1/TP01/Arguments/Arguments.class differ diff --git a/APL2.1/TP01/Arguments/Arguments.java b/APL2.1/TP01/Arguments/Arguments.java new file mode 100644 index 0000000..560b7ef --- /dev/null +++ b/APL2.1/TP01/Arguments/Arguments.java @@ -0,0 +1,5 @@ +public class Arguments { + public static void main(String[] args) { + for (String name : args) System.out.println("Bonjour " + name); + } +} \ No newline at end of file diff --git a/APL2.1/TP01/Demarrage/Demarrage.class b/APL2.1/TP01/Demarrage/Demarrage.class new file mode 100644 index 0000000..30d24f0 Binary files /dev/null and b/APL2.1/TP01/Demarrage/Demarrage.class differ diff --git a/APL2.1/TP01/Demarrage/Demarrage.java b/APL2.1/TP01/Demarrage/Demarrage.java new file mode 100644 index 0000000..0ed54f9 --- /dev/null +++ b/APL2.1/TP01/Demarrage/Demarrage.java @@ -0,0 +1,29 @@ +/** +* Prints all primitive types +* @version 1.0 05/02/22 +* @author Ewen Horville +*/ +public class Demarrage { + /** + * Main function which declares and prints all types.. + */ + public static void main(String[] args) { + byte a = 1; + short b = 50; + int c = 30; + long d = 64L; + boolean e = true; + char f = 'G'; + float g = 1.53f; + double h = 32.2d; + + System.out.println(a); + System.out.println(b); + System.out.println(c); + System.out.println(d); + System.out.println(e); + System.out.println(f); + System.out.println(g); + System.out.println(h); + } +} \ No newline at end of file diff --git a/APL2.1/TP01/Grille/Grille.class b/APL2.1/TP01/Grille/Grille.class new file mode 100644 index 0000000..f53d29a Binary files /dev/null and b/APL2.1/TP01/Grille/Grille.class differ diff --git a/APL2.1/TP01/Grille/Grille.java b/APL2.1/TP01/Grille/Grille.java new file mode 100644 index 0000000..a9b3840 --- /dev/null +++ b/APL2.1/TP01/Grille/Grille.java @@ -0,0 +1,15 @@ +public class Grille { + public static void main(String[] args) { + int size = Integer.parseInt(args[0]); + + for (int x = 0; x < size * 2 + 1; x++) { + for (int y = 0; y < size; y++) { + if (x % 2 == 0) System.out.print("+---"); + else System.out.print("| "); + } + + if (x % 2 == 0) System.out.println("+"); + else System.out.println("|"); + } + } +} \ No newline at end of file diff --git a/APL2.1/TP01/Somme/Somme.class b/APL2.1/TP01/Somme/Somme.class new file mode 100644 index 0000000..f6ee8d4 Binary files /dev/null and b/APL2.1/TP01/Somme/Somme.class differ diff --git a/APL2.1/TP01/Somme/Somme.java b/APL2.1/TP01/Somme/Somme.java new file mode 100644 index 0000000..72c01f6 --- /dev/null +++ b/APL2.1/TP01/Somme/Somme.java @@ -0,0 +1,10 @@ +public class Somme { + public static void main(String[] args) { + int sum = 0; + for (String nb : args) { + sum += Integer.parseInt(nb); + } + + System.out.println("Somme = " + sum); + } +} \ No newline at end of file diff --git a/APL2.1/TP01/Tri/Tri.class b/APL2.1/TP01/Tri/Tri.class new file mode 100644 index 0000000..e1e4a66 Binary files /dev/null and b/APL2.1/TP01/Tri/Tri.class differ diff --git a/APL2.1/TP01/Tri/Tri.java b/APL2.1/TP01/Tri/Tri.java new file mode 100644 index 0000000..5a1bb70 --- /dev/null +++ b/APL2.1/TP01/Tri/Tri.java @@ -0,0 +1,13 @@ +import java.util.Arrays; + +public class Tri { + public static void main(String[] args) { + int[] intArray = new int[args.length]; + for (int i = 0; i < args.length; i++) { + intArray[i] = Integer.parseInt(args[i]); + } + + Arrays.sort(intArray); + System.out.println(Arrays.toString(intArray)); + } +} \ No newline at end of file diff --git a/APL2.1/TP02/Boutons/Boutons.java b/APL2.1/TP02/Boutons/Boutons.java new file mode 100644 index 0000000..1632416 --- /dev/null +++ b/APL2.1/TP02/Boutons/Boutons.java @@ -0,0 +1,29 @@ +import javax.swing.*; +import java.awt.*; + +public class Boutons { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + + fenetre.setSize(500, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JButton BT1 = new JButton("OwO"); + fenetre.add(BT1, BorderLayout.WEST); + + JButton BT2 = new JButton("OwO"); + fenetre.add(BT2, BorderLayout.EAST); + + JButton BT3 = new JButton("OwO"); + fenetre.add(BT3, BorderLayout.NORTH); + + JButton BT4 = new JButton("OwO"); + fenetre.add(BT4, BorderLayout.SOUTH); + + JButton BT5 = new JButton("OwO"); + fenetre.add(BT5, BorderLayout.CENTER); + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP02/Choix/Choix.class b/APL2.1/TP02/Choix/Choix.class new file mode 100644 index 0000000..8fde239 Binary files /dev/null and b/APL2.1/TP02/Choix/Choix.class differ diff --git a/APL2.1/TP02/Choix/Choix.java b/APL2.1/TP02/Choix/Choix.java new file mode 100644 index 0000000..22ab185 --- /dev/null +++ b/APL2.1/TP02/Choix/Choix.java @@ -0,0 +1,25 @@ +import javax.swing.*; +import java.awt.*; + +public class Choix { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + fenetre.setSize(500, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + ButtonGroup houses = new ButtonGroup(); + JRadioButton gryffondor = new JRadioButton("Gryffondor"); + JRadioButton serpentard = new JRadioButton("Serpentard"); + JRadioButton serdaigle = new JRadioButton("Serdaigle"); + + houses.add(gryffondor); + houses.add(serpentard); + houses.add(serdaigle); + + fenetre.add(gryffondor, BorderLayout.NORTH); + fenetre.add(serpentard, BorderLayout.CENTER); + fenetre.add(serdaigle, BorderLayout.SOUTH); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP02/Contingences/Contingences.class b/APL2.1/TP02/Contingences/Contingences.class new file mode 100644 index 0000000..7e5c520 Binary files /dev/null and b/APL2.1/TP02/Contingences/Contingences.class differ diff --git a/APL2.1/TP02/Contingences/Contingences.java b/APL2.1/TP02/Contingences/Contingences.java new file mode 100644 index 0000000..882b56c --- /dev/null +++ b/APL2.1/TP02/Contingences/Contingences.java @@ -0,0 +1,29 @@ +import javax.swing.*; +import java.awt.*; + +public class Contingences { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + + fenetre.setSize(500, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JTextField myTextField = new JTextField("Hello World!"); + myTextField.setBackground(Color.GRAY); + myTextField.setForeground(new Color(0, 255, 0)); + fenetre.add(myTextField, BorderLayout.SOUTH); + + JTextArea myTextArea = new JTextArea("Hello World!"); + myTextArea.setBackground(Color.BLACK); + myTextArea.setForeground(new Color(0, 255, 0)); + myTextArea.setLineWrap(true); + + JScrollPane myPane = new JScrollPane(myTextArea); + myPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + myPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + fenetre.add(myPane, BorderLayout.CENTER); + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP02/Saisie/Saisie.java b/APL2.1/TP02/Saisie/Saisie.java new file mode 100644 index 0000000..0006919 --- /dev/null +++ b/APL2.1/TP02/Saisie/Saisie.java @@ -0,0 +1,24 @@ +import javax.swing.*; +import java.awt.*; + +public class Saisie { + public static void main(String[] args) { + JFrame fenetre = new JFrame(); + + fenetre.setSize(500, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JTextField MyTextField = new JTextField("Hello World!"); + MyTextField.setBackground(Color.GRAY); + MyTextField.setForeground(new Color(0, 255, 0)); + fenetre.add(MyTextField, BorderLayout.SOUTH); + + JTextArea MyTextArea = new JTextArea("Hello World!"); + MyTextArea.setBackground(Color.BLACK); + MyTextArea.setForeground(new Color(0, 255, 0)); + fenetre.add(MyTextArea, BorderLayout.CENTER); + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP02/Sirocco/Sirocco.java b/APL2.1/TP02/Sirocco/Sirocco.java new file mode 100644 index 0000000..f54a41b --- /dev/null +++ b/APL2.1/TP02/Sirocco/Sirocco.java @@ -0,0 +1,22 @@ +import javax.swing.*; +import java.awt.*; + +public class Sirocco { + public static void main(String[] args) { + // un objet pour servir de fenetre + JFrame fenetre = new JFrame(); + // on configure la fenetre + fenetre.setSize(500, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + // un composant pour afficher du texte + JLabel etiquette = new JLabel("Bonjour !"); + // on configure l'etiquette + etiquette.setHorizontalAlignment(JLabel.RIGHT); + etiquette.setVerticalAlignment(JLabel.BOTTOM); + // on ajoute le composant dans la fenetre, au milieu + fenetre.add(etiquette, BorderLayout.CENTER); + // et on montre le resultat + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP03/Damier/Damier.class b/APL2.1/TP03/Damier/Damier.class new file mode 100644 index 0000000..5eb3feb Binary files /dev/null and b/APL2.1/TP03/Damier/Damier.class differ diff --git a/APL2.1/TP03/Damier/Damier.java b/APL2.1/TP03/Damier/Damier.java new file mode 100644 index 0000000..873dad7 --- /dev/null +++ b/APL2.1/TP03/Damier/Damier.java @@ -0,0 +1,24 @@ +import javax.swing.*; +import java.awt.*; + +public class Damier { + public static void main(String[] args) { + int size = Integer.parseInt(args[0]); + + JFrame fenetre = new JFrame("Damier"); + fenetre.setSize(size * 50, size * 50); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + GridLayout grid = new GridLayout(size, size); + fenetre.setLayout(grid); + + for (int i = 0; i < size * size; i++) { + JPanel panel = new JPanel(); + if (i % 2 == 0) panel.setBackground(Color.CYAN); + else panel.setBackground(Color.WHITE); + fenetre.add(panel); + } + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP03/Question/Question.class b/APL2.1/TP03/Question/Question.class new file mode 100644 index 0000000..749fecd Binary files /dev/null and b/APL2.1/TP03/Question/Question.class differ diff --git a/APL2.1/TP03/Question/Question.java b/APL2.1/TP03/Question/Question.java new file mode 100644 index 0000000..575311e --- /dev/null +++ b/APL2.1/TP03/Question/Question.java @@ -0,0 +1,28 @@ +import javax.swing.*; +import java.awt.*; + +public class Question { + public static void main(String[] args) { + JFrame fenetre = new JFrame("Damier"); + fenetre.setSize(300, 200); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + + JLabel question = new JLabel("Aimez-vous les chiens ?", SwingConstants.CENTER); + question.setVerticalAlignment(SwingConstants.BOTTOM); + + JPanel buttonPanel = new JPanel(); + JButton yes = new JButton("Oui"); + JButton no = new JButton("Non"); + JButton noAnswer = new JButton("NSPP"); + + buttonPanel.add(yes, BorderLayout.CENTER); + buttonPanel.add(no, BorderLayout.CENTER); + buttonPanel.add(noAnswer, BorderLayout.CENTER); + + fenetre.add(buttonPanel, BorderLayout.CENTER); + fenetre.add(question, BorderLayout.NORTH); + fenetre.setVisible(true); + } +} \ No newline at end of file