-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vehicle.java
58 lines (52 loc) · 1.3 KB
/
Vehicle.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package org.KNUJavaLabs.HW.hw8;
/*
LabsJava4 Task 7.13
*/
interface Vehicle {
void ride();
}
abstract class HromadskyVehicle implements Vehicle{
String mark;
String number;
HromadskyVehicle(String number,String mark){
this.mark = mark;
this.number = number;
}
public void setMark(String mark) {
this.mark = mark;
}
public void setNumber(String number) {
this.number = number;
}
public String getMark() {
return this.mark;
}
public String getNumber() {
return this.number;
}
@Override
public void ride() {
System.out.println("HromadskyTransport "+this.mark+" with number "+this.number+" IS RIDING");
route();
}
public abstract void route ();
@Override
public String toString() {
return "HromadskyVehicle{" +
"mark='" + this.mark + '\'' +
", number='" + this.number + '\'' +
'}';
}
}
class Tram extends HromadskyVehicle{
int start;
int end;
Tram(String mark,String number,int start,int end){
super(number, mark);
this.start = start;
this.end = end;
}
public void route() {
System.out.println("From"+this.start+" To "+ this.end + " For "+(this.end-this.start)+" Miles" );
}
}