forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
36 lines (30 loc) · 750 Bytes
/
Car.java
File metadata and controls
36 lines (30 loc) · 750 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 {
public static final int MAX_SPEED = 250;
public static final int MIN_SPEED = 1;
public String name;
public Integer speed;
public Car() {
name = null;
speed = null;
}
public boolean setSpeed(int speed) {
if(speed >= MIN_SPEED && speed <= MAX_SPEED)
{
this.speed = speed;
return true;
}
return false;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass()) return false;
Car car = (Car) o;
return name.equals(car.name);
}
@Override
public int hashCode() {
return name.hashCode();
}
}