-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuch.java
More file actions
56 lines (49 loc) · 1.59 KB
/
Buch.java
File metadata and controls
56 lines (49 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sas.*;
import java.awt.Color;
/**
* @author
* @version
*/
public class Buch
{
private static final String[] TITELLISTE = {"Algorithmen","Datenstrukturen","Automatentheorie","Graphentheorie",
"Datenbanken","Java","Netzwerke","Kryptographie","Datenschutz","Urheberrecht","Objektorientierung",
"SQL","Raspberry Pi","Python","Roboter","App-Entwicklung","Informatik","3D-Druck","Linux","Server"};
// Objektvariablen der Bezugsobjekte
private Rectangle buch;
private Text etikett;
// Attribute (Instanzvariablen)
private int hoehe;
private int breite;
private String titel;
// Konstruktor
public Buch(int px)
{
hoehe = (int)(Math.random()*50+120);
breite = 24;
buch = new Rectangle(px,Buecherregal.YKANTE-hoehe,breite,hoehe);
int r = (int) (255 * Math.random());
int g = (int) (255 * Math.random());
int b = (int) (255 * Math.random());
buch.setColor(new Color(r, g, b));
titel = TITELLISTE[(int) (Math.random()*TITELLISTE.length)];
etikett = new Text(px+breite/2-6,Buecherregal.YKANTE-5,titel);
etikett.setFontSansSerif(true, 12);
etikett.turn(px + breite/2-6, Buecherregal.YKANTE-5, -90);
}
// Dienste
public int gibHoehe() {
return hoehe;
}
public int gibBreite() {
return breite;
}
public String gibTitel() {
return titel;
}
public void setzeXLinks(int px){
double dx = px - buch.getShapeX();
buch.move(dx,0);
etikett.move(dx,0);
}
}