-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyLine.java
More file actions
41 lines (36 loc) · 1023 Bytes
/
MyLine.java
File metadata and controls
41 lines (36 loc) · 1023 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
import java.awt.Color;
import java.awt.Graphics;
/**
* this class Declaration of class MyLine.
*/
public class MyLine extends MyShape
{
/**
* MyLine constructor initializes private vars with default values
*/
public MyLine()
{
super(); // call constructor to set values
} // end MyLine no-argument constructor
/**
* MyLine constructor initializes private vars 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
*/
public MyLine(int x1, int y1, int x2, int y2, Color myColor)
{
super(x1,y1,x2,y2,myColor);
}
/**
* draw method draw the line in the specified color
* @param g Graphics shape
*/
public void draw(Graphics g)
{
g.setColor(super.getColor());
g.drawLine(super.getX1(), super.getY1(), super.getX2(), super.getY2());
}
} // end class MyLine