TP06 - TP07 début
This commit is contained in:
parent
975abd0e19
commit
a5665f3b23
Binary file not shown.
@ -37,6 +37,6 @@ public class Segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Segment s2) {
|
public boolean equals(Segment s2) {
|
||||||
return this.start == s2.start && this.end == s2.end;
|
return (this.start.equals(s2.start) && this.end.equals(s2.end));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,6 @@ public class TestSegment {
|
|||||||
Segment s = new Segment(0, 10, 10, 0);
|
Segment s = new Segment(0, 10, 10, 0);
|
||||||
Segment s2 = new Segment(0, 10, 10, 0);
|
Segment s2 = new Segment(0, 10, 10, 0);
|
||||||
|
|
||||||
System.out.println(s.equals(s2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
APL2.1/TP06/Documentation/Documentation.class
Normal file
BIN
APL2.1/TP06/Documentation/Documentation.class
Normal file
Binary file not shown.
9
APL2.1/TP06/Documentation/Documentation.java
Normal file
9
APL2.1/TP06/Documentation/Documentation.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
public class Documentation {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
for (String str : args) {
|
||||||
|
System.out.println(str.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP06/Documentation/ToBase8.class
Normal file
BIN
APL2.1/TP06/Documentation/ToBase8.class
Normal file
Binary file not shown.
8
APL2.1/TP06/Documentation/ToBase8.java
Normal file
8
APL2.1/TP06/Documentation/ToBase8.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
public class ToBase8 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
for (String str : args) {
|
||||||
|
int nb = Integer.parseInt(str, 8);
|
||||||
|
System.out.println(Integer.toHexString(nb).toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
APL2.1/TP06/Documentation/reponses.txt
Normal file
4
APL2.1/TP06/Documentation/reponses.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
1. java.lang.Object
|
||||||
|
2. La classe Object
|
||||||
|
3. 10 (8 dont 2 surcharges)
|
||||||
|
4. 0 ?
|
BIN
APL2.1/TP06/Gris/Gris.class
Normal file
BIN
APL2.1/TP06/Gris/Gris.class
Normal file
Binary file not shown.
7
APL2.1/TP06/Gris/Gris.java
Normal file
7
APL2.1/TP06/Gris/Gris.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
|
public class Gris extends Color {
|
||||||
|
public Gris(int l) {
|
||||||
|
super(l, l, l);
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP06/Gris/TestGris.class
Normal file
BIN
APL2.1/TP06/Gris/TestGris.class
Normal file
Binary file not shown.
24
APL2.1/TP06/Gris/TestGris.java
Normal file
24
APL2.1/TP06/Gris/TestGris.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class TestGris {
|
||||||
|
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(new Gris(150));
|
||||||
|
else panel.setBackground(Color.WHITE);
|
||||||
|
fenetre.add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP06/Metrique/MetricPaper.class
Normal file
BIN
APL2.1/TP06/Metrique/MetricPaper.class
Normal file
Binary file not shown.
33
APL2.1/TP06/Metrique/MetricPaper.java
Normal file
33
APL2.1/TP06/Metrique/MetricPaper.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import java.awt.print.Paper;
|
||||||
|
|
||||||
|
public class MetricPaper extends Paper {
|
||||||
|
private static double toMetric(double inch) {
|
||||||
|
return inch * 2.54d;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double toInch(double metric) {
|
||||||
|
return metric / 2.54d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMetricHeight() {
|
||||||
|
return toMetric(this.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMetricWidth() {
|
||||||
|
return toMetric(this.getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMetricImageableX() {
|
||||||
|
return toMetric(this.getImageableX());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMetricImageableY() {
|
||||||
|
return toMetric(this.getImageableY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetricPaper() {
|
||||||
|
super();
|
||||||
|
this.setSize(toInch(210d), toInch(297d));
|
||||||
|
this.setImageableArea(toInch(15), toInch(15), toInch(180), toInch(267));
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP06/Metrique/MetricTest.class
Normal file
BIN
APL2.1/TP06/Metrique/MetricTest.class
Normal file
Binary file not shown.
8
APL2.1/TP06/Metrique/MetricTest.java
Normal file
8
APL2.1/TP06/Metrique/MetricTest.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import java.awt.print.Paper;
|
||||||
|
|
||||||
|
public class MetricTest {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
MetricPaper p = new MetricPaper();
|
||||||
|
System.out.println(p.getMetricHeight());
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP06/Nuancier/Nuance.class
Normal file
BIN
APL2.1/TP06/Nuancier/Nuance.class
Normal file
Binary file not shown.
30
APL2.1/TP06/Nuancier/Nuance.java
Normal file
30
APL2.1/TP06/Nuancier/Nuance.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Nuance extends Panel {
|
||||||
|
private Panel tagBox;
|
||||||
|
private Label colorTag;
|
||||||
|
private Color color;
|
||||||
|
|
||||||
|
private void createNuance(String colorCode) {
|
||||||
|
tagBox = new Panel();
|
||||||
|
tagBox.setBackground(Color.BLACK);
|
||||||
|
tagBox.setSize(new Dimension(getWidth(), 20));
|
||||||
|
color = Color.decode(colorCode);
|
||||||
|
this.setBackground(color);
|
||||||
|
this.add(tagBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Nuance(String colorCode) {
|
||||||
|
super();
|
||||||
|
setPreferredSize(new Dimension(100, 100));
|
||||||
|
createNuance(colorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Nuance(String colorCode, int x, int y) {
|
||||||
|
super();
|
||||||
|
setPreferredSize(new Dimension(100, 100));
|
||||||
|
setSize(new Dimension(x, y));
|
||||||
|
createNuance(colorCode);
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP06/Nuancier/TestNuance.class
Normal file
BIN
APL2.1/TP06/Nuancier/TestNuance.class
Normal file
Binary file not shown.
18
APL2.1/TP06/Nuancier/TestNuance.java
Normal file
18
APL2.1/TP06/Nuancier/TestNuance.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class TestNuance {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame fenetre = new JFrame("Damier");
|
||||||
|
fenetre.setSize(500, 300);
|
||||||
|
fenetre.setLocation(100, 100);
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.setLayout(new GridLayout(1, 3));
|
||||||
|
|
||||||
|
fenetre.add(new Nuance("#FF0000", 100, 100));
|
||||||
|
fenetre.add(new Nuance("#00FF00", 100, 100));
|
||||||
|
fenetre.add(new Nuance("#0000FF", 100, 100));
|
||||||
|
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP07/Formes/Formes.class
Normal file
BIN
APL2.1/TP07/Formes/Formes.class
Normal file
Binary file not shown.
32
APL2.1/TP07/Formes/Formes.java
Normal file
32
APL2.1/TP07/Formes/Formes.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
class NewJFrame extends JComponent {
|
||||||
|
public NewJFrame() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics brush) {
|
||||||
|
Graphics newBrush = brush.create();
|
||||||
|
|
||||||
|
if (this.isOpaque()) {
|
||||||
|
newBrush.setColor(this.getBackground());
|
||||||
|
newBrush.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
newBrush.setColor(this.getForeground());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Formes {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JFrame f = new JFrame("Formes");
|
||||||
|
f.setSize(500, 500);
|
||||||
|
f.setLocation(100, 100);
|
||||||
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
f.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
APL2.1/TP07/Formes/NewJFrame.class
Normal file
BIN
APL2.1/TP07/Formes/NewJFrame.class
Normal file
Binary file not shown.
BIN
APL2.1/TP07/Formes/cercles.png
Normal file
BIN
APL2.1/TP07/Formes/cercles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue
Block a user