forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
36 lines (28 loc) · 678 Bytes
/
Car.java
File metadata and controls
36 lines (28 loc) · 678 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
public class Car {
private String name;
private double speed;
public Car(String name, double speed) {
this.name = name;
this.speed = speed;
if (!isCorrectSpeed()) this.speed = -1;
}
public boolean isCorrectSpeed() {
if (speed <= 0 || speed > 250) return false;
return true;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
public double getDistance() {
return 24 * speed;
}
}