-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompareFeatures.java
More file actions
53 lines (43 loc) · 1.08 KB
/
CompareFeatures.java
File metadata and controls
53 lines (43 loc) · 1.08 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
class Car{
String model,color;
public void setColor(String c){
color = c;
}
public void setModel(String name){
model = name;
}
public String getColor(){
return color;
}
public String getModel(){
return model;
}
}
class Maruti extends Car{
public void compareColor(Maruti m){
if(color.equals(m.color)){
System.out.println("Same Color");
}else{
System.out.println("Different Color");
}
}
public void compareModel(Maruti m){
if(model.equals(m.model)){
System.out.println("Same Model");
}else{
System.out.println("Different Model");
}
}
}
public class CompareFeatures {
public static void main(String[] args){
Maruti m1 = new Maruti();
Maruti m2 = new Maruti();
m1.setColor("red");
m1.setModel("nano");
m2.setColor("red");
m2.setModel("wagonr");
m1.compareColor(m2);
m2.compareModel(m1);
}
}