-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
66 lines (43 loc) · 2.43 KB
/
Solution.java
File metadata and controls
66 lines (43 loc) · 2.43 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
54
55
56
57
58
59
60
61
62
63
64
65
66
//And I went unto the angel, and said unto him, Give me the little book. And he said unto me, Take it, and eat it up; and it shall make thy belly bitter, but it shall be in thy mouth sweet as honey. (Revelation 10:9)
package com.javarush.task.task36.task3609;
/*
Рефакторинг MVC
*/
public class Solution {
public static void main(String[] args) {
//Fetch car record from the database
CarModel model = retrieveCarFromDatabase();
//Create a view : to show car's speed on speedometer(console)
SpeedometerView view = new SpeedometerView();
CarController controller = new CarController(model, view);
controller.updateView();
//Update model data
controller.speedUp(15);
controller.updateView();
//Update model data
controller.speedUp(50);
controller.updateView();
//Update model data
controller.speedDown(7);
controller.updateView();
}
private static CarModel retrieveCarFromDatabase() {
CarModel currentCar = new CarModel();
currentCar.setBrand("Nissan");
currentCar.setModel("Almera classic");
currentCar.setSpeed(0);
currentCar.setMaxSpeed(200);
return currentCar;
}
}
/*
Рефакторинг MVC
Перемести некоторые методы в нужные классы, что бы получить паттерн MVC. Если необходимо - внеси изменения в метод main, которые отражают внесенные тобой изменения. Поведение программы при этом не должно измениться.
НЕ изменяй названия классов, методов и полей.
Требования:
1. Вывод программы должен остаться без изменений.
2. Необходимо переместить метод void speedUp(int) из класса CarModel в класс CarController.
3. Необходимо переместить метод void speedDown(int) из класса CarModel в класс CarController.
4. В методе main класса Solution метод speedUp необходимо вызывать у контроллера, а не у модели.
5. В методе main класса Solution метод speedDown необходимо вызывать у контроллера, а не у модели.
*/