-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyRectangle.java
More file actions
54 lines (43 loc) · 1.17 KB
/
Copy pathMyRectangle.java
File metadata and controls
54 lines (43 loc) · 1.17 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
import java.awt.Color;
import java.awt.Graphics;
/**
* this class Declaration of class MyRectangle.
*/
public class MyRectangle extends MyBoundedShape
{
/**
* MyRectangle constructor initializes private vars with default values
*/
public MyRectangle()
{
super();
}
/**
* MyRectangle constructor with input values
*@param x1 x coordinate of first endpoint
*@param y1 y coordinate of first endpoint
*@param x2 x coordinate of second endpoint
*@param y2 y coordinate of second endpoint
*@param myColor the color of the shape
*@param filled if the shape is filled
*/
public MyRectangle(int x1, int y1, int x2, int y2,
Color myColor, boolean filled)
{
super(x1,y1,x2,y2,myColor,filled);
}
/**
* draw method draws an rectangle in the specified color
* @param g Graphics shape
*/
public void draw(Graphics g)
{
g.setColor(super.getColor());
if (isFilled())
g.fillRect(getUpperLeftX(), getUpperLeftY(),
getWidth(), getHeight());
else
g.drawRect(getUpperLeftX(), getUpperLeftY(),
getWidth(), getHeight());
}
} // end class MyRectangle