-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapeMenu.m
More file actions
76 lines (62 loc) · 1.96 KB
/
ShapeMenu.m
File metadata and controls
76 lines (62 loc) · 1.96 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
67
68
69
70
71
72
73
74
75
76
while (true)
prompt = "\n\nChoose Shape:\n1. Rectangle\n2. Circle\n" + ...
"3. Tringle\n4. Equilateral Triangle\n5. Square\n" + ...
"6. Quit\n\nYour Choice: ";
choice = input(prompt);
switch choice
case 1 % Rectangle
Length = input("Enter Length: ");
Width = input("Enter Width: ");
color = selectColor();
rect = Rectangle(Length, Width);
rect = rect.setColor(color);
rect.Display;
rect.Draw;
case 2 % Circle
Radius = input("Enter Radius: ");
color = selectColor();
circle = Circle(Radius);
circle = circle.setColor(color);
circle.Display;
circle.Draw;
case 3 % Tringle
Base = input("Enter Base: ");
Hieght = input("Enter Hieght: ");
color = selectColor();
triangle = Triangle(Base, Hieght);
triangle = triangle.setColor(color);
triangle.Display;
triangle.Draw;
case 4 % EquilateralTriangle
Side = input("Enter Side: ");
color = selectColor();
eTriangle = EquilateralTriangle(Side);
eTriangle = eTriangle.setColor(color);
eTriangle.Display;
eTriangle.Draw;
case 5 % Square
Side = input("Enter Side: ");
color = selectColor();
square = Square(Side);
square = square.setColor(color);
square.Display;
square.Draw;
otherwise
fprintf("\nExiting...\n");
break;
end
end
function r = selectColor()
colorChoice = input("Select A color:\n1. Red\n2. Green\n" + ...
"3. Blue\n\nYour Choice: ");
color = 'black';
switch colorChoice
case 1
color = 'red';
case 2
color = 'green';
case 3
color = 'blue';
end
r = color;
end