forked from zouldapp/JavaWorkshopCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolymorphism1.java
37 lines (28 loc) · 914 Bytes
/
Polymorphism1.java
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
public class Polymorphism1 {
public String color;
public int size;
public boolean isVisible;
public Polymorphism1() {
this("Red");
}
public Polymorphism1(String color) {
this.color = color;
}
public Polymorphism1(String color, int size) {
this(color);
this.size = size;
}
public Polymorphism1(String color, int size, boolean isVisible) {
this(color, size);
this.isVisible = isVisible;
}
public static void main(String [] args) {
// Polymorphism1 poly = new Polymorphism1();
// Polymorphism1 poly = new Polymorphism1("Blue");
// Polymorphism1 poly = new Polymorphism1("Blue", 42);
Polymorphism1 poly = new Polymorphism1("Blue", 42, true);
System.out.println(poly.size);
System.out.println(poly.color);
System.out.println(poly.isVisible);
}
}