-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
46 lines (33 loc) · 716 Bytes
/
Square.java
File metadata and controls
46 lines (33 loc) · 716 Bytes
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
import java.awt.Color;
import java.util.Random;
public class Square extends Shape {
private int shapeWidth;
public Square(int shapeWidth){
this.shapeWidth = shapeWidth;
}
@Override
public Color getRandomColor() {
Random random = new Random();
float r, g, b;
r = random.nextFloat();
g = random.nextFloat();
b = random.nextFloat();
return new Color(r, g, b);
}
@Override
public int getShapeWidth(){
return this.shapeWidth;
}
@Override
public int getShapeHeight(){
return this.shapeWidth;
}
@Override
public int getCenterX(int mouseX) {
return mouseX - this.shapeWidth/2;
}
@Override
public int getCenterY(int mouseY) {
return mouseY - this.shapeWidth/2;
}
}