-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
72 lines (69 loc) · 1.84 KB
/
test.java
File metadata and controls
72 lines (69 loc) · 1.84 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
68
69
70
71
72
class shape {
void draw(float radius){
System.out.println("Draw the cirlce with radius"+radius);
}
void draw(float base, float height){
System.out.println("Draw the triangle with base"+base+"height"+height);
}
void draw(float side,Boolean a){
System.out.println("Draw the square with sides"+side);
}
void erase(float radius){
System.out.println("Erase the circle with radius"+radius);
}
void erase(float base, float height){
System.out.println("Draw the triangle with base"+base+"Height"+height);
}
void erase(float side, Boolean a){
System.out.println("Draw the square with sides"+side);
}
}
class Circle extends shape{
float radius;
Circle(float radius){
this.radius=radius;
}
void draw(){
super.draw(radius);}
void erase(){
super.erase(radius);
}
}
class Triangle extends shape{
float base;
float height;
Triangle(float base, float height){
this.base=base;
this.height=height;
}
void draw(){
super.draw(base,height);}
void erase(){
super.erase(base,height);
}
}
class Square extends shape{
float side;
Square(float side){
this.side=side;
}
void draw(){
super.draw(side, true);
}
void erase(){
super.erase(side,true);
}
}
public class test{
public static void main(String[] args) {
Circle c1= new Circle(5);
Triangle t1= new Triangle(6, 7);
Square s1= new Square(6);
c1.draw();
t1.draw();
s1.draw();
c1.erase();
t1.erase();
s1.erase();
}
}