Skip to content

Commit 231e03f

Browse files
authored
to the angel,&said to him, Give me little book
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)
1 parent 64fa3c9 commit 231e03f

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
//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)
3+
4+
package com.javarush.task.task36.task3609;
5+
6+
/*
7+
Рефакторинг MVC
8+
*/
9+
10+
public class Solution {
11+
public static void main(String[] args) {
12+
//Fetch car record from the database
13+
CarModel model = retrieveCarFromDatabase();
14+
15+
//Create a view : to show car's speed on speedometer(console)
16+
SpeedometerView view = new SpeedometerView();
17+
18+
CarController controller = new CarController(model, view);
19+
controller.updateView();
20+
21+
//Update model data
22+
controller.speedUp(15);
23+
controller.updateView();
24+
25+
//Update model data
26+
controller.speedUp(50);
27+
controller.updateView();
28+
29+
//Update model data
30+
controller.speedDown(7);
31+
controller.updateView();
32+
}
33+
34+
private static CarModel retrieveCarFromDatabase() {
35+
CarModel currentCar = new CarModel();
36+
currentCar.setBrand("Nissan");
37+
currentCar.setModel("Almera classic");
38+
currentCar.setSpeed(0);
39+
currentCar.setMaxSpeed(200);
40+
return currentCar;
41+
}
42+
}
43+
44+
/*
45+
Рефакторинг MVC
46+
47+
Перемести некоторые методы в нужные классы, что бы получить паттерн MVC. Если необходимо - внеси изменения в метод main, которые отражают внесенные тобой изменения. Поведение программы при этом не должно измениться.
48+
49+
НЕ изменяй названия классов, методов и полей.
50+
51+
52+
53+
54+
55+
Требования:
56+
57+
1. Вывод программы должен остаться без изменений.
58+
59+
2. Необходимо переместить метод void speedUp(int) из класса CarModel в класс CarController.
60+
61+
3. Необходимо переместить метод void speedDown(int) из класса CarModel в класс CarController.
62+
63+
4. В методе main класса Solution метод speedUp необходимо вызывать у контроллера, а не у модели.
64+
65+
5. В методе main класса Solution метод speedDown необходимо вызывать у контроллера, а не у модели.
66+
*/

0 commit comments

Comments
 (0)