Fin du TP Heritage
This commit is contained in:
BIN
DEV2.1/TP05/BaseHuit.class
Normal file
BIN
DEV2.1/TP05/BaseHuit.class
Normal file
Binary file not shown.
10
DEV2.1/TP05/BaseHuit.java
Normal file
10
DEV2.1/TP05/BaseHuit.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class BaseHuit {
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0 || args.length >= 2) {
|
||||
System.out.println("Nombre d'arguments incorrect.");
|
||||
}
|
||||
else {
|
||||
System.out.println(Integer.toHexString(Integer.parseInt(args[0], 8)));
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP05/Documentation.class
Normal file
BIN
DEV2.1/TP05/Documentation.class
Normal file
Binary file not shown.
17
DEV2.1/TP05/Documentation.java
Normal file
17
DEV2.1/TP05/Documentation.java
Normal file
@@ -0,0 +1,17 @@
|
||||
// La classe String se trouve dans le package java.lang
|
||||
// Elle hérite de la classe Object
|
||||
// Il existe 8 méthodes héritées de la classe Object
|
||||
|
||||
|
||||
public class Documentation {
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
System.out.println("Aucun argument en ligne de commande.");
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println(args[i].toUpperCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP05/Gris.class
Normal file
BIN
DEV2.1/TP05/Gris.class
Normal file
Binary file not shown.
22
DEV2.1/TP05/Gris.java
Normal file
22
DEV2.1/TP05/Gris.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Gris extends Color {
|
||||
|
||||
public Gris(int n) {
|
||||
super(n,n,n);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Gris couleur = new Gris(50);
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(200, 200);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
JTextArea etiquette = new JTextArea("Bonjour !");
|
||||
etiquette.setBackground(couleur); // Fonctionne
|
||||
fenetre.add(etiquette, BorderLayout.CENTER);
|
||||
fenetre.setVisible(true);
|
||||
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP05/Metrique.class
Normal file
BIN
DEV2.1/TP05/Metrique.class
Normal file
Binary file not shown.
74
DEV2.1/TP05/Metrique.java
Normal file
74
DEV2.1/TP05/Metrique.java
Normal file
@@ -0,0 +1,74 @@
|
||||
import java.awt.print.Paper;
|
||||
|
||||
public class Metrique extends Paper {
|
||||
public Metrique() {
|
||||
super();
|
||||
// WIDTH : 21*(1cm in inches)*72 HEIGHT : 29,7*(1cm en inches)*72
|
||||
this.setSize(595.27584, 841.88952);
|
||||
// MARGE : 1.5*(1cm in inches)*72 DECALAGE : 3cm = 85.0392 1/72inches
|
||||
this.setImageableArea(42.519672, 42.519672, 510.23664, 756.85032);
|
||||
}
|
||||
|
||||
public double getMetricHeight() {
|
||||
return this.getHeight() / 72 * 25.4; // 1inch = 25.4mm
|
||||
}
|
||||
|
||||
public double getMetricWidth() {
|
||||
return this.getWidth() / 72 * 25.4; // 1inch = 25.4mm
|
||||
}
|
||||
|
||||
public double getMetricImageableHeight() {
|
||||
return this.getImageableHeight() / 72 * 25.4; // 1inch = 25.4mm
|
||||
}
|
||||
|
||||
public double getMetricImageableWidth() {
|
||||
return this.getImageableWidth() / 72 * 25.4; // 1inch = 25.4mm
|
||||
}
|
||||
|
||||
public double getMetricImageableX() {
|
||||
return this.getImageableX() / 72 * 25.4; // 1inch = 25.4mm
|
||||
}
|
||||
|
||||
public double getMetricImageableY() {
|
||||
return this.getImageableY() / 72 * 25.4; // 1inch = 25.4mm
|
||||
}
|
||||
|
||||
public void setMetricImageableArea(double x, double y, double width, double height) {
|
||||
this.setImageableArea(
|
||||
x * 0.393701 * 72,
|
||||
y * 0.393701 * 72,
|
||||
width * 0.393701 * 72,
|
||||
height * 0.393701 * 72
|
||||
);
|
||||
}
|
||||
|
||||
public void setMetricSize(double width, double height) {
|
||||
this.setSize(
|
||||
width * 0.393701 * 72,
|
||||
height * 0.393701 * 72
|
||||
);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Metrique papier = new Metrique();
|
||||
System.out.println("TESTS DE DEPART : ");
|
||||
System.out.println("" + papier.getMetricHeight());
|
||||
System.out.println("" + papier.getMetricWidth());
|
||||
System.out.println("" + papier.getMetricImageableHeight());
|
||||
System.out.println("" + papier.getMetricImageableWidth());
|
||||
System.out.println("" + papier.getMetricImageableX());
|
||||
System.out.println("" + papier.getMetricImageableY());
|
||||
|
||||
System.out.println("MODIFICATION DES DIMENSIONS : ");
|
||||
papier.setMetricSize(50,100);
|
||||
System.out.println("" + papier.getMetricHeight());
|
||||
System.out.println("" + papier.getMetricWidth());
|
||||
|
||||
System.out.println("MODIFICATION DE LA TAILLE IMAGEABLE: ");
|
||||
papier.setMetricImageableArea(5,5,40,80);
|
||||
System.out.println("" + papier.getMetricImageableX());
|
||||
System.out.println("" + papier.getMetricImageableY());
|
||||
System.out.println("" + papier.getMetricImageableHeight());
|
||||
System.out.println("" + papier.getMetricImageableWidth());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user