-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRollsRoyce.java
More file actions
48 lines (33 loc) · 1.08 KB
/
RollsRoyce.java
File metadata and controls
48 lines (33 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
package javaIntroduction;
public class RollsRoyce extends Sedan{
//attributes
private String model;
//constructor(Default)
public RollsRoyce() {
super();
model = "Ghost Series II";
}
//constructor(overloaded)
public RollsRoyce(String color, int numWheels, String model) {
super(color , numWheels);
this.model = model;
}
//method overriding
@Override
public String sound() {
return super.sound()+"mmmm";
}
public static void main(String [] args) {
RollsRoyce rr = new RollsRoyce();
RollsRoyce rr2 = new RollsRoyce("Darkest Tungsten", 4 ,"Wraith(2021)");
System.out.println("Color: "+rr.color);
System.out.println("Model: "+rr.model);
System.out.println("Wheels: "+rr.numWheels);
System.out.println("Sound: "+rr.sound());
System.out.println("\n######################################\n");
System.out.println("Color: "+rr2.color);
System.out.println("Model: "+rr2.model);
System.out.println("Wheels: "+rr2.numWheels);
System.out.println("Sound: "+rr2.sound());
}
}