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
53 lines (48 loc) · 1.16 KB
/
Car.java
File metadata and controls
53 lines (48 loc) · 1.16 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
public class Car {
// третья попытка
int speed;
String name;
public Car(int speed,String name){
this.speed = speed;
this.name = name;
}
}
/* вторая попытка
int speed;
String model;
public Car(String model, int speed) {
this.model = model;
this.speed = speed;
}
}*/
/* первая попытка
private int speed;
private String model;
public int getSpeed() {
return speed;
}
public void setSpeed() {
Scanner scan = new Scanner(System.in);
int speed = scan.nextInt();
if (speed < 0 || speed >=250){
System.out.println("Введите верное значение скорости");
setSpeed();
}
else {
this.speed = speed;
}
}
public String getModel() {
return model;
}
public void setModel() {
Scanner scan = new Scanner(System.in);
String model = scan.nextLine();
if (model.isEmpty()){
System.out.println("Введите корректное имя");
setModel();
}
this.model = model;
}
}
*/