This repository has been archived by the owner on Dec 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.cpp
93 lines (87 loc) · 2.59 KB
/
interface.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "interface.h"
#include <iostream>
void drawFigure(Rhombus &rhombus) {
cout << "Rhombus " << endl;
cout << "vertical diagonal: " << rhombus.getHLength() << endl;
cout << "horizontal diagonal: " << rhombus.getWLength() << endl;
cout << "center x: " << rhombus.getCenter().getX() << " y: " << rhombus.getCenter().getY() << endl;
cout << "P: " << rhombus.getP() << endl;
cout << "S: " << rhombus.getS() << endl;
}
void drawCommand() {
cout<<endl<<"command list"<<endl;
cout << "1: draw" << endl;
cout << "2: set vertical diagonal" << endl;
cout << "3: set Horizontal diagonal" << endl;
cout << "4: set color" << endl;
cout << "5: set style" << endl;
cout << "6: set x,y";
}
void setStyle(Rhombus &rhombus) {
cout << "Input style 1,2 or 3";
int style;
cin >> style;
bool error;
do {
error = false;
switch (style) {
case 1:
rhombus.setStyle(stSolid);
break;
case 2:
rhombus.setStyle(stClarity);
break;
case 3:
rhombus.setStyle(stHidden);
break;
default:
cout << "undefined style";
error = true;
}
} while (error);
}
void ModifyFigure(Rhombus &rhombus) {
int command = 1;
while (command != 0) {
switch (command) {
case 1:
drawFigure(rhombus);
break;
case 2:
cout << "input vertical diagonal: ";
double vdiagonal;
cin >> vdiagonal;
rhombus.setHLength(vdiagonal);
break;
case 3:
cout << "input horizontal diagonal: ";
double hdiagonal;
cin >> hdiagonal;
rhombus.setWLength(hdiagonal);
break;
case 4:
cout << "Input color: ";
int color;
cin >> color;
rhombus.setColor(color);
break;
case 5:
setStyle(rhombus);
break;
case 6:
double x, y;
cout << "Enter x and y separated by a space: ";
cin >> x >> y;
{
auto *center = new Location(x, y);
rhombus.setCenter(*center);
}
break;
default:
cout << "undefined command";
}
drawCommand();
cout <<endl<< "input command: ";
cin >> command;
}
}