-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvehiclemain.java
110 lines (81 loc) · 2.19 KB
/
vehiclemain.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import java.io.*;
class vehicle
{
private int wheels;
private int speed;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
void setdata() throws Exception
{
System.out.println("Enter The no. of wheels::\n");
wheels= Integer.parseInt(br.readLine());
System.out.println("Enter The max speed::\n");
speed= Integer.parseInt(br.readLine());
}
void disp()
{
System.out.println("No OF Wheel is " + wheels);
System.out.println("Speed is " + speed);
}
int getdata()
{
return speed;
}
}
class car extends vehicle
{
private int pass;
void setdata() throws Exception
{
System.out.println("Enter car information");
super.setdata();
System.out.println("Enter The max no. of passengers::\n");
pass = Integer.parseInt(br.readLine());
}
void disp()
{
System.out.println("CAR INFORMATION IS....");
super.disp();
System.out.println("No of Passenger is "+pass);
}
}
class truck extends vehicle
{
private int load;
void setdata() throws Exception
{
System.out.println("Enter Truck information");
super.setdata();
System.out.println("Enter The max load::\n");
load = Integer.parseInt(br.readLine());
}
void disp()
{
System.out.println("TRUCK INFORMATION IS....");
super.disp();
System.out.println("MAx Load is "+load);
}
}
class compare
{
void check(car c, truck t)
{
if(c.getdata() > t.getdata())
System.out.println("CAR SPEED IS MORE THAN TRUCk SPEED");
else
System.out.println("TRUCK SPEED IS MORE THAN CAR SPEED");
}
}
class vehiclemain
{
public static void main(String gd[])throws Exception
{
car c1=new car();
truck t1 = new truck();
c1.setdata();
t1.setdata();
c1.disp();
t1.disp();
compare c = new compare();
c.check(c1,t1);
}
}