-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
40 lines (33 loc) · 847 Bytes
/
Copy pathCar.java
File metadata and controls
40 lines (33 loc) · 847 Bytes
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
import java.util.Random;
public class Car implements Vehicle, GPS, Radio {
String licensePlate = "6TRJ244";
public void start() {
System.out.println("Starting Engine...");
}
public void stop() {
System.out.println("Stopping Engine...");
}
public void getCoordinates() {
Random rd = new Random();
float x, y;
x = rd.nextFloat(100);
y = rd.nextFloat(100);
System.out.println("Car's current coordinate: " + x + ", " + y);
}
public void startRadio() {
System.out.println("Start Radio...");
}
public void stopRadio() {
System.out.println("Stop Radio...");
}
public static void main(String[] args) {
Car tesla = new Car();
tesla.start();
System.out.println("Car Number Plate: " + tesla.licensePlate);
tesla.blowHorn();
tesla.getCoordinates();
tesla.startRadio();
tesla.stopRadio();
tesla.stop();
}
}