-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment7A.txt
174 lines (140 loc) · 3.67 KB
/
Assignment7A.txt
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
Matthew Dal Santo
ITDEV-117
Assignment 7A - More Class Diagrams/Pseudocode
Page 292
Exercise #8
a. Create a Class Diagram and pseudo code for Pizza Class.
Design a class named Pizza. Data fields include a string field for toppings (such
as pepperoni) and numeric fields for diameter in inches (such as 12) and price
(such as 13.99). Include methods to get and set values for each of these fields.
Create the class diagram and write the pseudocode that defines the class.
Pizza
-toppings : string
-diameter : num
-price : num
+setToppings(extras : string) : void
+setDiameter(size : num) : void
+setPrice(money : num) : void
+getToppings() : string
+getDiameter() : num
+getPrice() : num
class Pizza
// Declarations
private string toppings
private num diameter
private num price
public void setToppings(string extras)
toppings = extras
return
public void setDiameter(num size)
diameter = size
return
public void setPrice(num money)
price = money
return
public string getToppings()
return toppings
public num getDiameter()
return diameter
public num getPrice()
return price
endClass
b. Application Main() - pseudo code that declares TWO objects and sets and displays (gets) their values.
Pseudocode for Main():
class PizzaMain
public static void main()
// Declarations
Pizza myPizza
Pizza yourPizza
myPizza.setToppings("Peperonni")
myPizza.setDiameter(12)
myPizza.setPrice(13.99)
yourPizza.setToppings("Pineapple")
yourPizza.setDiameter(14)
yourPizza.setPrice(15.99)
output "Pizza 1 info: "
output myPizza.getToppings()
output myPizza.getDiameter()
output myPizza.getPrice()
output "Pizza 2 info: "
output yourPizza.getToppings()
output yourPizza.getDiameter()
output yourPizza.getPrice()
return
endClass
Extra Credit:
Implement your Class and MainModule in a programming language of your choice from the Visual Studio Language set(C#, VB, C++)
Implimented with C#. Code included with Assignment #7A submission. Also below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ITDEV117Assignment7A
{
class Program
{
static void Main(string[] args)
{
Pizza myPizza = new Pizza();
Pizza yourPizza = new Pizza();
myPizza.setToppings("Peperonni");
myPizza.setDiameter(12);
myPizza.setPrice(13.99);
yourPizza.setToppings("Pineapple");
yourPizza.setDiameter(14);
yourPizza.setPrice(15.99);
Console.WriteLine("Pizza 1 info: ");
Console.WriteLine(myPizza.getToppings());
Console.WriteLine(myPizza.getDiameter());
Console.WriteLine(myPizza.getPrice());
Console.WriteLine("");
Console.WriteLine("Pizza 2 info: ");
Console.WriteLine(yourPizza.getToppings());
Console.WriteLine(yourPizza.getDiameter());
Console.WriteLine(yourPizza.getPrice());
Console.WriteLine("");
Console.WriteLine("Press enter to exit...");
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ITDEV117Assignment7A
{
class Pizza
{
// Declarations
private string toppings;
private int diameter;
private double price;
public void setToppings(string extras)
{
toppings = extras;
}
public void setDiameter(int size)
{
diameter = size;
}
public void setPrice(double money)
{
price = money;
}
public string getToppings()
{
return toppings;
}
public int getDiameter()
{
return diameter;
}
public double getPrice()
{
return price;
}
}
}