-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA6_9InterfaceVehicle.java
More file actions
59 lines (59 loc) · 1.69 KB
/
A6_9InterfaceVehicle.java
File metadata and controls
59 lines (59 loc) · 1.69 KB
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
package com.company;
interface Vehicle{
public void getcolor();
public void getnumber();
public void getconsumption();
}
class TwoWheeler implements Vehicle{
String name;
String color;
int number;
float fuel;
TwoWheeler(String name,String color,int number,float fuel){
this.name=name;
this.color=color;
this.number=number;
this.fuel=fuel;
}
public void getcolor(){
System.out.println(name+" twowheeler color: "+ color);
}
public void getnumber(){
System.out.println(name+" twowheeler number: "+ number);
}
public void getconsumption(){
System.out.println(name+" twowheeler consumed: "+ fuel+"litre fuel");
}
}
class FourWheeler implements Vehicle{
String name;
String color;
int number;
float fuel;
FourWheeler(String name,String color,int number,float fuel){
this.name=name;
this.color=color;
this.number=number;
this.fuel=fuel;
}
public void getcolor(){
System.out.println(name+" fourwheeler color: " +color);
}
public void getnumber(){
System.out.println(name+" twowheeler number: "+number);
}
public void getconsumption(){
System.out.println(name+" twowheeler consumed: "+fuel+"litre fuel");
}
}
public class A6_9InterfaceVehicle {
public static void main(String[] args){
TwoWheeler RE=new TwoWheeler("ABCD","Blue",1234,201);
RE.getcolor();
RE.getconsumption();
RE.getcolor();
FourWheeler M=new FourWheeler("ABCD","White",1234,400);
M.getcolor();
M.getnumber();
M.getnumber(); }
}