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
30 lines (24 loc) · 761 Bytes
/
Car.java
File metadata and controls
30 lines (24 loc) · 761 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
public class Car {
private String name; // название автомобиля
private int speed; // скорость автомобиля, км/ч
public Car(String name, int speed) {
this.name = name;
this.speed = speed;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
// Метод для вывода информации об автомобиле
public void displayInfo() {
System.out.println("Автомобиль: " + name + ", скорость: " + speed + " км/ч");
}
}