-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDrawErase.java
More file actions
62 lines (59 loc) · 850 Bytes
/
DrawErase.java
File metadata and controls
62 lines (59 loc) · 850 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Shape
{
public void draw(String shape)
{
System.out.println("Drawing " + shape);
}
public void erase(String shape)
{
System.out.println("Erasing "+shape);
}
}
class Circle extends Shape
{
public void draw()
{
super.draw("Circle");
}
public void erase()
{
super.erase("Circle");
}
}
class Triangle extends Shape
{
public void draw()
{
super.draw("Triangle");
}
public void erase()
{
super.erase("Triangle");
}
}
class Square extends Shape
{
public void draw()
{
super.draw("Square");
}
public void erase()
{
super.erase("Square");
}
}
class DrawErase
{
public static void main(String args[])
{
Circle c = new Circle();
Triangle t = new Triangle();
Square s= new Square();
c.draw();
c.erase();
t.draw();
t.erase();
s.draw();
s.erase();
}
}