diff --git a/DEV2.1/TD1/Fraction.java b/DEV2.1/TD1/Fraction.java new file mode 100644 index 0000000..efc935e --- /dev/null +++ b/DEV2.1/TD1/Fraction.java @@ -0,0 +1,39 @@ +public class Fraction +{ + private int numerateur; + private int denominateur; + + public Fraction(int n, int d) + { + this.numerateur = n; + this.denominateur = d; + } + + private static int pgcd(int a, int b) + { + int pgdc=0; + for ( int i = 0 ; i <= a && i <= b ; i++ ) + { + if(a%i==0 && b%i==0) + { + pgcd = i; + } + } + return pgcd; + } + + public void reduire() + { + int pgcd = Fraction.pgcd(this.denominateur,this.numerateur); + this.denominateur/=pgcd; + this.numerateur/=pgcd; + } + + public + + public String toString() + { + return this.numerateur+"/"+this.denominateur; + } + +} \ No newline at end of file diff --git a/DEV2.1/TP1/Bonjour.class b/DEV2.1/TP1/Bonjour.class new file mode 100644 index 0000000..1a3e1b2 Binary files /dev/null and b/DEV2.1/TP1/Bonjour.class differ diff --git a/DEV2.1/TP1/Bonjour.java b/DEV2.1/TP1/Bonjour.java new file mode 100644 index 0000000..60dc8cd --- /dev/null +++ b/DEV2.1/TP1/Bonjour.java @@ -0,0 +1,19 @@ +/** +* Cette classe est une simple coquille pour recevoir la méthode principale +* +* @version 1.1 09 March 2014 +* @author Luc Hernandez +*/ +public class Bonjour { + + /** + * Affiche «Bonjour !» + * + * @param args la liste des arguments de la ligne de commande (inutilisée ici) + */ + public static void main(String[] args) { + for (String i : args ) { + System.out.println("Bonjour "+i+" !"); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP1/Bonjour2.class b/DEV2.1/TP1/Bonjour2.class new file mode 100644 index 0000000..02ade9c Binary files /dev/null and b/DEV2.1/TP1/Bonjour2.class differ diff --git a/DEV2.1/TP1/Bonjour2.java b/DEV2.1/TP1/Bonjour2.java new file mode 100644 index 0000000..9aa618d --- /dev/null +++ b/DEV2.1/TP1/Bonjour2.java @@ -0,0 +1,21 @@ +import javax.swing.*; +import java.awt.*; + +public class Bonjour2 { + 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.CENTER); + // 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/DEV2.1/TP1/Bouton.class b/DEV2.1/TP1/Bouton.class new file mode 100644 index 0000000..ee9ce6c Binary files /dev/null and b/DEV2.1/TP1/Bouton.class differ diff --git a/DEV2.1/TP1/Bouton.java b/DEV2.1/TP1/Bouton.java new file mode 100644 index 0000000..0a1f24f --- /dev/null +++ b/DEV2.1/TP1/Bouton.java @@ -0,0 +1,35 @@ +import javax.swing.*; +import java.awt.*; + +public class Bouton { + 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 + JButton b1 = new JButton("Bouton 1"); + b1.setHorizontalAlignment(JButton.CENTER); + fenetre.add(b1, BorderLayout.SOUTH); + + JButton b2 = new JButton("BoutonBoutonBBoutonBoutonBoutonBoutonBoutonBoutonBoutonouton 2"); + b2.setHorizontalAlignment(JButton.CENTER); + fenetre.add(b2, BorderLayout.CENTER); + + JButton b3 = new JButton("Bouton 3"); + b3.setHorizontalAlignment(JButton.CENTER); + fenetre.add(b3, BorderLayout.NORTH); + + JButton b4 = new JButton("Bouton 4"); + b4.setHorizontalAlignment(JButton.CENTER); + fenetre.add(b4, BorderLayout.WEST); + + JButton b5 = new JButton("Bouton 5"); + b5.setHorizontalAlignment(JButton.CENTER); + fenetre.add(b5, BorderLayout.EAST); + // et on montre le resultat + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP1/Grille.class b/DEV2.1/TP1/Grille.class new file mode 100644 index 0000000..dc4afb1 Binary files /dev/null and b/DEV2.1/TP1/Grille.class differ diff --git a/DEV2.1/TP1/Grille.java b/DEV2.1/TP1/Grille.java new file mode 100644 index 0000000..7523ee3 --- /dev/null +++ b/DEV2.1/TP1/Grille.java @@ -0,0 +1,29 @@ +import java.util.Arrays; + +public class Grille +{ + public static void main(String[] args) + { + int h = Integer.parseInt(args[0]); + for (int i = 0;i < h; i++ ) + { + System.out.print("+"); + for (int j = 0;j < h; j++ ) + { + System.out.print("-+"); + } + System.out.println(); + System.out.print("|"); + for (int j = 0;j < h; j++ ) + { + System.out.print(" |"); + } + System.out.println(); + } + System.out.print("+"); + for (int j = 0;j < h; j++ ) + { + System.out.print("-+"); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP1/Saisie.class b/DEV2.1/TP1/Saisie.class new file mode 100644 index 0000000..0197cba Binary files /dev/null and b/DEV2.1/TP1/Saisie.class differ diff --git a/DEV2.1/TP1/Saisie.java b/DEV2.1/TP1/Saisie.java new file mode 100644 index 0000000..2f17584 --- /dev/null +++ b/DEV2.1/TP1/Saisie.java @@ -0,0 +1,23 @@ +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 txt = new JTextField(); + txt.setBounds(0,100,500,300); + fenetre.add(txt, BorderLayout.SOUTH); + + JTextArea txt2 = new JTextArea(); + txt2.setVerticalAlignment(JTextArea.CENTER); + fenetre.add(txt2, BorderLayout.CENTER); + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP1/Sirocco.class b/DEV2.1/TP1/Sirocco.class new file mode 100644 index 0000000..2d1fdc5 Binary files /dev/null and b/DEV2.1/TP1/Sirocco.class differ diff --git a/DEV2.1/TP1/Sirocco.java b/DEV2.1/TP1/Sirocco.java new file mode 100644 index 0000000..55e49c1 --- /dev/null +++ b/DEV2.1/TP1/Sirocco.java @@ -0,0 +1,21 @@ +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("Sirocco"); + // on configure l'etiquette + etiquette.setHorizontalAlignment(JLabel.RIGHT); + // on ajoute le composant dans la fenetre, au milieu + fenetre.add(etiquette, BorderLayout.SOUTH); + // et on montre le resultat + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP1/Somme.class b/DEV2.1/TP1/Somme.class new file mode 100644 index 0000000..36eba86 Binary files /dev/null and b/DEV2.1/TP1/Somme.class differ diff --git a/DEV2.1/TP1/Somme.java b/DEV2.1/TP1/Somme.java new file mode 100644 index 0000000..e09dfa3 --- /dev/null +++ b/DEV2.1/TP1/Somme.java @@ -0,0 +1,14 @@ +public class Somme +{ + public static void main(String[] args) + { + int n = 0; + int sum = 0; + for (String i : args ) + { + n = Integer.parseInt(i); + sum += n; + } + System.out.println(sum); + } +} \ No newline at end of file diff --git a/DEV2.1/TP1/Tri.class b/DEV2.1/TP1/Tri.class new file mode 100644 index 0000000..cfc8bd0 Binary files /dev/null and b/DEV2.1/TP1/Tri.class differ diff --git a/DEV2.1/TP1/Tri.java b/DEV2.1/TP1/Tri.java new file mode 100644 index 0000000..3f36405 --- /dev/null +++ b/DEV2.1/TP1/Tri.java @@ -0,0 +1,23 @@ +import java.util.Arrays; + +public class Tri +{ + public static void main(String[] args) + { + int n = 0; + int j = 0; + int[] tabN = new int[args.length]; + for (String i : args ) + { + n = Integer.parseInt(i); + tabN[j] = n; + j++; + } + Arrays.sort(tabN); + + for (int i : tabN ) + { + System.out.print(i); + } + } +} \ No newline at end of file