This commit is contained in:
HORVILLE 2022-02-07 17:26:04 +01:00
parent c7ec385a55
commit 759ba2dc5d
21 changed files with 253 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,5 @@
public class Arguments {
public static void main(String[] args) {
for (String name : args) System.out.println("Bonjour " + name);
}
}

Binary file not shown.

View File

@ -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);
}
}

Binary file not shown.

View File

@ -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("|");
}
}
}

Binary file not shown.

View File

@ -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);
}
}

BIN
APL2.1/TP01/Tri/Tri.class Normal file

Binary file not shown.

13
APL2.1/TP01/Tri/Tri.java Normal file
View File

@ -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));
}
}

View File

@ -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);
}
}

Binary file not shown.

View File

@ -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);
}
}

Binary file not shown.

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

Binary file not shown.

View File

@ -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);
}
}

Binary file not shown.

View File

@ -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);
}
}