diff --git a/DEV.2.1/TP/TP6-Dessin/2.Sautoir/MainSautoir.java b/DEV.2.1/TP/TP6-Dessin/2.Sautoir/MainSautoir.java index 9e76906..2f75f98 100644 --- a/DEV.2.1/TP/TP6-Dessin/2.Sautoir/MainSautoir.java +++ b/DEV.2.1/TP/TP6-Dessin/2.Sautoir/MainSautoir.java @@ -17,7 +17,6 @@ public class MainSautoir { } } - frame.setSize(500,500); frame.setLocation(500,250); diff --git a/DEV.2.1/TP/TP6-Dessin/3.Acceuil/Acceuil.java b/DEV.2.1/TP/TP6-Dessin/3.Acceuil/Acceuil.java new file mode 100644 index 0000000..27d7b55 --- /dev/null +++ b/DEV.2.1/TP/TP6-Dessin/3.Acceuil/Acceuil.java @@ -0,0 +1,26 @@ +import javax.swing.*; +import java.awt.*; + +public class Acceuil extends JComponent { + private Image logo; + + public Acceuil() { + super(); + this.logo = Toolkit.getDefaultToolkit().getImage("img.png"); + } + + @Override + protected void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + secondPinceau.setColor(this.getForeground()); + + Font fonte = new Font("TimesRoman", Font.BOLD,24); + secondPinceau.setColor(new Color(128,0,128)); + secondPinceau.setFont(fonte); + secondPinceau.drawString("IUT", 10, 20); + + secondPinceau.drawImage(this.logo, 20,30, this); + + + } +} \ No newline at end of file diff --git a/DEV.2.1/TP/TP6-Dessin/3.Acceuil/MainAcceuil.java b/DEV.2.1/TP/TP6-Dessin/3.Acceuil/MainAcceuil.java new file mode 100644 index 0000000..ef1bc49 --- /dev/null +++ b/DEV.2.1/TP/TP6-Dessin/3.Acceuil/MainAcceuil.java @@ -0,0 +1,14 @@ +import javax.swing.*; +import java.awt.*; + +public class MainAcceuil { + public static void main(String[] args) { + JFrame frame = new JFrame("Acceuil"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setUndecorated(true); //https://waytolearnx.com/2020/05/changer-la-bordure-dune-jframe-java.html + + frame.setSize(278,183); + frame.setLocation(500,250); + frame.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV.2.1/TP/TP7-Polymorphisme/1./Moto.java b/DEV.2.1/TP/TP7-Polymorphisme/1./Moto.java new file mode 100644 index 0000000..baf5aff --- /dev/null +++ b/DEV.2.1/TP/TP7-Polymorphisme/1./Moto.java @@ -0,0 +1,12 @@ +public class Moto implements Vehicule { + + @Override + public int nbRoues() { + return 2; + } + + @Override + public String sorte() { + return "Moto"; + } +} \ No newline at end of file diff --git a/DEV.2.1/TP/TP7-Polymorphisme/1./Test.java b/DEV.2.1/TP/TP7-Polymorphisme/1./Test.java new file mode 100644 index 0000000..be240e7 --- /dev/null +++ b/DEV.2.1/TP/TP7-Polymorphisme/1./Test.java @@ -0,0 +1,23 @@ +import javax.swing.JOptionPane; + +public class Test { + public static void main(String[] args) { + Vehicule v; + Object[] choix = {"Voiture", "Moto"}; + + int reponse = JOptionPane.showOptionDialog(null, + "Quel v\u00E9hicule choisissez-vous ?", + "Question", + JOptionPane.DEFAULT_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + choix, + null); + if (reponse == 0) + v = new Voiture(); + else + v = new Moto(); + System.out.println("Une "+v.sorte()+" poss\u00E8de "+v.nbRoues()+" roues."); + } +} + diff --git a/DEV.2.1/TP/TP7-Polymorphisme/1./Vehicule.java b/DEV.2.1/TP/TP7-Polymorphisme/1./Vehicule.java new file mode 100644 index 0000000..66598f4 --- /dev/null +++ b/DEV.2.1/TP/TP7-Polymorphisme/1./Vehicule.java @@ -0,0 +1,5 @@ +public interface Vehicule { + + public int nbRoues(); + public String sorte(); +} \ No newline at end of file diff --git a/DEV.2.1/TP/TP7-Polymorphisme/1./Voiture.java b/DEV.2.1/TP/TP7-Polymorphisme/1./Voiture.java new file mode 100644 index 0000000..d692aa1 --- /dev/null +++ b/DEV.2.1/TP/TP7-Polymorphisme/1./Voiture.java @@ -0,0 +1,12 @@ +public class Voiture implements Vehicule { + + @Override + public String sorte() { + return "Voiture"; + } + + @Override + public int nbRoues() { + return 4; + } +} \ No newline at end of file