Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

1 using LAb7;

2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7
8 namespace LAb7
9 {
10 {
11 abstract class Shape
12 {
13 internal abstract double CalculateArea();
14 protected int radius, height, width, depth;
15 }
16 {
17 class realstate
18 {
19 protected int room, floor, area;
20 }
21 internal class Circle: Shape
22 {
23 // private int radius;
24 internal void circle()
25 {
26 Console.WriteLine("Enter the radius of the circle:");
27 radius = int.Parse(Console.ReadLine());
28 }
29 internal override double CalculateArea()
30 {
31 return 3.1416 * radius * radius;
32 }
33 internal string Radius()
34 {
35 return $"Circle with radius {radius}";
36 }
37 }
38 internal class Rectangle:Shape
39 {
40 // private int height, width;
41 internal void rectangle()
42 {
43 Console.WriteLine("Enter the height and width of the rectangle:");
44 height = int.Parse(Console.ReadLine());
45 width = int.Parse(Console.ReadLine());
46 }
47 internal override double CalculateArea()
48 {
49 return height * width;
50 }
51 internal string rect()
52 {
53 return $"Rectangle with height {height} and width {width}";
54 }
55 }
56 internal class Cube:Shape
57 {
58 //s private int height, width, depth;
59 internal void cube()
60 {
61 Console.WriteLine("Enter the height, width, and depth of the cube:");
62 height = int.Parse(Console.ReadLine());
63 width = int.Parse(Console.ReadLine());
64 depth = int.Parse(Console.ReadLine());
65 }
66 internal override double CalculateArea()
67 {
68 return 2 * ((height * width) + (width * depth) + (height * depth));
69 }
70 internal string Tocube()
71 {
72 return $"Cube with height {height}, width {width}, and depth {depth}";
73 }
74 }
75 internal class Office:realstate
76 {
77 public Office()
78 {
79 Console.WriteLine("Enter floor, room, and area");
80 floor = int.Parse(Console.ReadLine());
81 room = int.Parse(Console.ReadLine());
82 area = int.Parse(Console.ReadLine());
83 }
84 public int GetArea()
85 {
86 return area;
87 }
88 internal string office()
89 {
90 return $"Office in {floor}th floor with {room} rooms and an area of {area}
sqft";
91 }
92 }
93 internal class Apartment:realstate
94 {
95 internal Apartment()
96 {
97 Console.WriteLine("Enter floor, room, and area");
98 floor = int.Parse(Console.ReadLine());
99 room = int.Parse(Console.ReadLine());
100 area = int.Parse(Console.ReadLine());
101 }
102 internal int GetArea()
103 {
104 return area;
105 }
106 internal string apartment()
107 {
108 return $"Apartment in {floor}th floor with {room} rooms and an area of
{area} sqft";
109 }
110 }
111 internal class Hostel:realstate
112 {
113 internal Hostel()
114 {
115 Console.WriteLine("Enter room and area");
116 room = int.Parse(Console.ReadLine());
117 area = int.Parse(Console.ReadLine());
118 }
119 internal int GetArea()
120 {
121 return area;
122 }
123 internal string hostel()
124 {
125 return $"Hostel with {room} rooms and an area of {area} sqft";
126 }
127 }
128
129 class Program
130 {
131 static void Main(string[] args)
132 {
133 Shape[] shapes = new Shape[100];
134 realstate[] Real = new realstate[100];
135 int circleCount = 0;
136 int rectangleCount = 0;
137 int cubeCount = 0;
138 double totalCircleArea = 0;
139 double totalRectangleArea = 0;
140 double totalCubeArea = 0;
141 int shapeCount = 0;
142 int hostelcount = 0, apartmentcount = 0, officecount = 0, realcount = 0;
143 int harea = 0, aarea = 0, oarea = 0;
144 string[] shapeTypes = new string[100];
145 string[] shapeNames = new string[100];
146 while (true)
147 {
148 Console.WriteLine("1. Geometric");
149 Console.WriteLine("2. Realstate");
150 Console.WriteLine("3. Exit");
151 int x = int.Parse(Console.ReadLine());
152 if (x == 1)
153 {
154 while (true)
155 {
156 Console.WriteLine("1. Add circle");
157 Console.WriteLine("2. Add rectangle");
158 Console.WriteLine("3. Add cube");
159 Console.WriteLine("4. Item list");
160 Console.WriteLine("5. Statistics");
161 Console.WriteLine("6. Back");
162 Console.WriteLine("7. Exit");
163
164 int n = int.Parse(Console.ReadLine());
165
166 if (n == 1)
167 {
168 Circle circle = new Circle();
169 circle.circle();
170 totalCircleArea += circle.CalculateArea();
171 shapeTypes[shapeCount] =circle.Radius();
172 circleCount++;
173 shapeCount++;
174 }
175 else if (n == 2)
176 {
177 Rectangle rectangle = new Rectangle();
178 rectangle.rectangle();
179 totalRectangleArea += rectangle.CalculateArea();
180 shapeTypes[shapeCount] =rectangle.rect();
181 rectangleCount++;
182 shapeCount++;
183 }
184 else if (n == 3)
185 {
186 Cube cube = new Cube();
187 cube.cube();
188 totalCubeArea += cube.CalculateArea();
189 shapeTypes[shapeCount] =cube.Tocube();
190 cubeCount++;
191 shapeCount++;
192 }
193 else if (n == 4)
194 {
195 Console.WriteLine("Item List:");
196 for (int i = 0; i < shapeCount; i++)
197 {
198 Console.WriteLine($"{i + 1} is {shapeTypes[i]}");
199
200 }
201 }
202 else if (n == 5)
203 {
204 Console.WriteLine($"Number of circles: {circleCount}");
205 Console.WriteLine($"Number of rectangles: {rectangleCount}");
206 Console.WriteLine($"Number of cubes: {cubeCount}");
207 Console.WriteLine($"Total area of circles:
{totalCircleArea:F3}");
208 Double p = (totalCircleArea * 100) / (totalCircleArea +
totalRectangleArea + totalCubeArea);
209 Console.WriteLine($"Percentage of circle: {p}");
210 Console.WriteLine($"Total area of rectangles:
{totalRectangleArea}");
211 p = (totalRectangleArea * 100) / (totalCircleArea +
totalRectangleArea + totalCubeArea);
212 Console.WriteLine($"Percentage of rectangle: {p}");
213 Console.WriteLine($"Total area of cubes: {totalCubeArea}");
214 p = (totalCubeArea * 100) / (totalCircleArea +
totalRectangleArea + totalCubeArea);
215 Console.WriteLine($"Percentage of cube: {p}");
216 Console.WriteLine($"Total area: {totalCircleArea +
totalRectangleArea + totalCubeArea}");
217 }
218 else if (n == 6)
219 {
220 break;
221 }
222 else if (n == 7)
223 {
224 Console.WriteLine("--------THE END----------");
225 Environment.Exit(0);
226 }
227 }
228 }
229 else if (x == 2)
230 {
231 while (true)
232 {
233 Console.WriteLine("1. Apartment");
234 Console.WriteLine("2. Hostel");
235 Console.WriteLine("3. Office");
236 Console.WriteLine("4. Itemlist");
237 Console.WriteLine("5. Statistics");
238 Console.WriteLine("6. Back");
239 Console.WriteLine("7. Exit");
240 int y = int.Parse(Console.ReadLine());
241
242 if (y == 1)
243 {
244 Apartment apartment = new Apartment();
245 shapeNames[realcount] = apartment.apartment();
246 aarea += apartment.GetArea();
247 apartmentcount++;
248 realcount++;
249 }
250 else if (y == 2)
251 {
252 Hostel hostel = new Hostel();
253 shapeNames[realcount]=hostel.hostel();
254 harea += hostel.GetArea();
255 hostelcount++;
256 realcount++;
257 }
258 else if (y == 3)
259 {
260 Office office = new Office();
261 shapeNames[realcount]=office.office();
262 oarea += office.GetArea();
263 officecount++;
264 realcount++;
265 }
266 else if (y == 4)
267 {
268 Console.WriteLine("Item List:");
269 for (int i = 0; i < realcount; i++)
270 {
271 Console.WriteLine($"{i + 1} is {shapeNames[i]}");
272 }
273 }
274 else if (y == 5)
275 {
276 Console.WriteLine($"Total area of Apartment: {aarea} sqrft");
277 Double p = (aarea * 100.00) / (aarea + harea + oarea);
278 Console.WriteLine($"Percentage of Apartment: {p} ");
279 Console.WriteLine($"Total area of Hostel: {harea} sqrft");
280 p = (harea * 100.00) / (aarea + harea + oarea);
281 Console.WriteLine($"Percentage of Hostel: {p}");
282 Console.WriteLine($"Total area of Office: {oarea} sqrft");
283 p = (oarea * 100.00) / (aarea + harea + oarea);
284 Console.WriteLine($"Percentage of office: {p}");
285 Console.WriteLine($"Total area: {aarea + harea + oarea}
sqrft");
286 }
287 else if (y == 6)
288 {
289 break;
290 }
291 else if (y == 7)
292 {
293 Console.WriteLine("--------THE END----------");
294 Environment.Exit(0);
295 }
296 }
297 }
298 else if (x == 3)
299 {
300 Console.WriteLine("--------THE END----------");
301 Environment.Exit(0);
302 }
303 }
304 }
305 }
306 }
307

You might also like