Professional Documents
Culture Documents
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
67
68
69
70
71
72
73
View::View(Model *model) {
this->model = model;
}
void View::showValue() {
if (model != NULL) {
cout << "n============";
cout << "n====" << model->getValue() << "====";
cout << "n============n";
}
}
void View::showMenu() {
cout << "n------------------------n";
cout << "1 - Setn";
cout << "2 - Increasen";
cout << "3 - Decreasen";
cout << "4 - Exitn";
cout << "Choose: ";
}
void View::process() {
int choice;
do {
showMenu();
cin >> choice;
switch (choice) {
case 1:
cout << "Enter a integer value: ";
int value;
cin >> value;
model->setValue(value);
showValue();
break;
case 2:
model->increase();
cout << "Increasing successful!";
showValue();
break;
case 3:
model->decrease();
cout << "Decreasing successful!";
showValue();
break;
case 4:
break;
default:
74
75
76
77
78 }
79
80 int
81
82
83
84
85
86 }
8
9
10
11
12 };
13 #endif
void setValue(int);
int getValue();
void increase();
void decrease();
#ifndef FILENAME_H
#define FILENAME_H
// t code ca bn vo y
#endif
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
void View::showValue() {
cout << "===============n";
cout << "====" << model->getValue() << "====n";
cout << "================n";
}
void View::showMenu() {
cout << "n==============n";
cout << "0 - Show valuen";
cout << "1 - Set valuen";
cout << "2 - Increasen";
cout << "3 - Decreasen";
cout << "4 - Exitn";
cout << "Choose: ";
}
void View::process() {
int choice = -1;
do {
showMenu();
cin >> choice;
switch (choice) {
case 0:
showValue();
break;
case 1:
cout << "Enter a integer number: ";
int tmp;
cin >> tmp;
model->setValue(tmp);
showValue();
break;
case 2:
model->increase();
showValue();
break;
case 3:
model->decrease();
showValue();
break;
case 4:
break;
default:
cout << "Please choose from 0 to 4!n";
break;
}
56
57 }