import javax.swing.*;
import java.awt.*;
class Unspezifisch extends Component{
int x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4;
public Unspezifisch(int x_1, int y_1, int x_2, int y_2, int x_3, int y_3, int x_4, int y_4){
this.x_1 = x_1;
this.y_1 = y_1;
this.x_2 = x_2;
this.y_2 = y_2;
this.x_3 = x_3;
this.y_3 = y_3;
this.x_4 = x_4;
this.y_4 = y_4;
}
public void paint (Graphics g){
g.drawLine(x_1, y_1, x_2, y_2);
g.drawLine(x_2, y_2, x_3, y_3); // 4 Linien = 1 Viereck
g.drawLine(x_3, y_3, x_4, y_4);
g.drawLine(x_4, y_4, x_1, y_1);
}
}
class Trapez extends Unspezifisch{
public Trapez(int x,int y,int h,int v){
super (v, 0, y, 0, 0, h, x, h);
}
}
class Rechteck extends Unspezifisch{
public Rechteck(int x_kante, int y_kante){
super (0, 0, x_kante, 0, 0, y_kante, x_kante, y_kante);
x_1 = 0;
y_1 = 0;
x_2= x_kante;
y_2 = 0;
x_3 = 0;
y_3 = y_kante;
x_4 = x_kante;
y_4 = y_kante;
}
}
class Quadrat extends Rechteck{
public Quadrat(int x_kante){
super(x_kante,x_kante);
}
}
class Zeichenfläche extends Canvas {
//Unspezifisch[] myVierecke;
// public Zeichenfläche( ) {
// myVierecke = new Unspezifisch[100];
// }
public static void main (String args[]){
Zeichenfläche myZeichenfläche = new Zeichenfläche();
Quadrat myQuadrat = new Quadrat (12);
Rechteck myRechteck = new Rechteck (5,20);
Trapez myTrapez = new Trapez (11,4,21,13);
Unspezifisch myUnspezifisch = new Unspezifisch (16,10,23,18,12,14,25,10);
myZeichenfläche.add(myRechteck);
JFrame myFenster = new JFrame ("myFenster");
myFenster.setSize (305,299);
myFenster.add(myZeichenfläche);
myFenster.setVisible(true);
}
}