-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.java
39 lines (31 loc) · 824 Bytes
/
Car.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
public class Car {
private String brand;
private String color;
private int year;
public Car(String brand, String color, int year) {
this.brand = brand;
this.color = color;
this.year = year;
}
public String getBrand() {
return brand;
}
public String getColor() {
return color;
}
public int getYear() {
return year;
}
public void start() {
System.out.println("The " + color + " " + brand + " is starting.");
}
public void accelerate() {
System.out.println("The " + color + " " + brand + " is accelerating.");
}
public void brake() {
System.out.println("The " + color + " " + brand + " is braking.");
}
public void honk() {
System.out.println("Honk! Honk!");
}
}