-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZostera.java
More file actions
94 lines (83 loc) · 2.26 KB
/
Zostera.java
File metadata and controls
94 lines (83 loc) · 2.26 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package q3;
import java.awt.*;
//ofri rom:208891804
//avigail shekasta:209104314
public class Zostera extends Immobile {
int size;
int x;
int y;
public Color colorr = Color.GREEN;
public Zostera(int size,int x,int y){
/**
* constructor
*/
super("Zostera");
this.size=size;
this.x=x;
this.y=y;
}
public Zostera(){
/**
* call the super constructor for init the name
*/
super("Zostera");
}
public void draw(Graphics g){
/**
* draw the sea planet on the panel
*/
Graphics2D g2 = ( Graphics2D ) g ;
g2.setStroke ( new BasicStroke ( 3 ) ) ;
g2.setColor ( colorr ) ;
g.drawLine ( x , y , x , y - size ) ;
g.drawLine ( x - 2 , y , x - 10 , y - size * 9 / 10 ) ;
g.drawLine ( x + 2 , y , x + 10 , y - size * 9 / 10 ) ;
g.drawLine ( x - 4 , y , x - 20 , y - size * 4 / 5 ) ;
g.drawLine ( x + 4 , y , x + 20 , y - size * 4 / 5 ) ;
g.drawLine ( x - 6 , y , x - 30 , y - size * 7 / 10 ) ;
g.drawLine ( x + 6 , y , x + 30 , y - size * 7 / 10 ) ;
g.drawLine ( x - 8 , y , x - 40 , y - size * 4 / 7 ) ;
g.drawLine ( x + 8 , y , x + 40 , y - size * 4 / 7 ) ;
g2.setStroke ( new BasicStroke ( 1 ) ) ;
}
@Override
public void drawCreature(Graphics g) {
/**
* call the draw method via the interface
*/
draw(g);
}
@Override
public void set_obj(int size, int x, int y) {
/**
*set this object parameters
*/
name="Zostera";
this.size=size;
this.x=x;
this.y=y;
}
@Override
public int get_size() {
return size;
}
@Override
public int get_x() {
return x;
}
@Override
public int get_y() {
return y;
}
@Override
public memento saveStateToMemento() {
return new memento("Zostera",size,x, y);
}
@Override
public void getStateFromMemento(memento m) {
size=m.get_size();
x=m.get_x_front();
y=m.get_y_front();
colorr=m.get_Colorr();
}
}