-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava 2 vehicle.java
79 lines (68 loc) · 1.36 KB
/
java 2 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.util.*;
abstract class Vehicle
{
String yom, name;
int wheel;
abstract void putData(String a, String b);
abstract void getData();
}
class TwoWheeler extends Vehicle
{
TwoWheeler()
{
this.wheel = 2;
}
void putData(String y, String n)
{
this.yom = y;
this.name = n;
}
void getData()
{
System.out.println("Bike details: \n1) Name: "+this.name+"\n2) Year of Manufacture: "+this.yom+"\n3) No. of Wheels: "+this.wheel);
}
}
final class FourWheeler extends Vehicle
{
void putData(String y, String n)
{
this.yom = y;
this.name = n;
this.wheel = 4;
}
void getData()
{
System.out.println("Car details: \n1) Name: "+this.name+"\n2) Year of Manufacture: "+this.yom+"\n3) No. of Wheels: "+this.wheel);
}
}
class MyTwoWheeler extends TwoWheeler
{
MyTwoWheeler()
{
super();
}
void putData(String y)
{
this.name = "Splendor";
this.yom = y;
}
void getData()
{
System.out.println("Bike details: \n1) Name: "+this.name+"\n2) Year of Manufacture: "+this.yom+"\n3) No. of Wheels: "+this.wheel);
}
}
class VehicleMain
{
public static void main(String[] args)
{
MyTwoWheeler S1 = new MyTwoWheeler();
TwoWheeler S2 = new TwoWheeler();
FourWheeler S3 = new FourWheeler();
S1.putData("2014");
S1.getData();
S2.putData("2015", "Gixxer SF");
S2.getData();
S3.putData("2016", "Brezza");
S3.getData();
}
}