-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise1.java
More file actions
43 lines (38 loc) · 858 Bytes
/
Copy pathExercise1.java
File metadata and controls
43 lines (38 loc) · 858 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
class Cycle {
private String name = "Cycle";
public void move(Cycle c){
System.out.println("Cycle " + c);
}
public String toString(){
return this.name;
}
}
class Unicycle extends Cycle{
private String name = "UNICYCLE";
public String toSring(){
return this.name;
}
}
class Bicycle extends Cycle{
private String name = "BICYCLE";
public String toSring(){
return this.name;
}
}
class Tricycle extends Cycle{
private String name = "TRICYCLE";
public String toSring(){
return this.name;
}
}
public class Exercise1{
public static void ride(Cycle i){
i.move(i);
}
public static void main(String[] args){
Tricycle tricycle = new Tricycle();
Bicycle bicycle = new Bicycle();
ride(tricycle);
ride(bicycle);
}
}