This commit is contained in:
Simon SAYE BABU 2023-02-10 11:52:05 +01:00
parent f0e71f54e1
commit 9751315d1a
17 changed files with 224 additions and 0 deletions

39
DEV2.1/TD1/Fraction.java Normal file
View File

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

BIN
DEV2.1/TP1/Bonjour.class Normal file

Binary file not shown.

19
DEV2.1/TP1/Bonjour.java Normal file
View File

@ -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 &laquo;Bonjour !&raquo;
*
* @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+" !");
}
}
}

BIN
DEV2.1/TP1/Bonjour2.class Normal file

Binary file not shown.

21
DEV2.1/TP1/Bonjour2.java Normal file
View File

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

BIN
DEV2.1/TP1/Bouton.class Normal file

Binary file not shown.

35
DEV2.1/TP1/Bouton.java Normal file
View File

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

BIN
DEV2.1/TP1/Grille.class Normal file

Binary file not shown.

29
DEV2.1/TP1/Grille.java Normal file
View File

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

BIN
DEV2.1/TP1/Saisie.class Normal file

Binary file not shown.

23
DEV2.1/TP1/Saisie.java Normal file
View File

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

BIN
DEV2.1/TP1/Sirocco.class Normal file

Binary file not shown.

21
DEV2.1/TP1/Sirocco.java Normal file
View File

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

BIN
DEV2.1/TP1/Somme.class Normal file

Binary file not shown.

14
DEV2.1/TP1/Somme.java Normal file
View File

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

BIN
DEV2.1/TP1/Tri.class Normal file

Binary file not shown.

23
DEV2.1/TP1/Tri.java Normal file
View File

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