-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
67 lines (67 loc) · 1.5 KB
/
Square.java
File metadata and controls
67 lines (67 loc) · 1.5 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
import java.awt.*;
/**
* Creates a square with an x coordinate, y coordinate and integer value
* @author Max Bernstein, Chris Hinstorff, Marco Valente
*
*/
public class Square {
private int xcoord, ycoord, value;
/**
* Creates a square at (x,y)
* @param x the x coordinate
* @param y the y coordinate
*/
public Square(int x, int y) {
xcoord = x;
ycoord = y;
value = 0;
}
/**
* Sets the squares value
* @param v the value
*/
public void setValue(int v) {
value = v;
}
/**
* Returns the squares value
* @return value of the square
*/
public int getValue() {
return value;
}
/**
* Returns the x coordinate
* @return x coordinate
*/
public int getX() {
return xcoord;
}
/**
* Returns the y coordinate
* @return y coordinate
*/
public int getY() {
return ycoord;
}
/**
* Paints the square
* @param g the Graphics Object
*/
public void paint(Graphics g) {
if(value == 0) {
}
else if(value == 1) {
You you = new You(xcoord, ycoord);
you.paint(g);
}
else if(value == 2) {
Mho mho = new Mho(xcoord, ycoord);
mho.paint(g);
}
else if(value == 3) {
Fence fence = new Fence(xcoord, ycoord);
fence.paint(g);
}
}
}