Question: In C# , no top level statements. Tip: Create a Class Library and add it to your project. Assignment 2 : Shape Area Calculator Objective:

In C#, no top level statements.
Tip: Create a Class Library and add it to your project.
Assignment 2: Shape Area Calculator
Objective: Design a set of classes to compute the area of various shapes (e.g., Circle, Rectangle, Triangle). Start with an abstract class Shape with the abstract methods CalculateArea() and CalculatePerimeter().
Shape Area Perimeter Terms
Circle A =\pi \times r2 Circumference =2\pi r r = radius of the circle
Triangle A =(1)/(2)\times b \times h S = a+b+c b = base
h = height
a,b and c are the sides of the triangle
Square A = a2 P =4a a = length of side
Rectangle A = l \times w P =2(l + w) l = length
w = width
Parallelogram A = b \times h P =2(a+b) a = side
b=base
h=vertical height
Requirements:
Abstract base class called Shape with common Properties {get; set;} USE BACKING FIELD VARIABLES of Height and Width, you can assume that the a Circles radius is half of either the Height or Width.
Three derived classes Circle, Square, Triangle
Store the objects in a Collection object (List, Array, HashSet, etc...) objects in the collection will be of type Shape
Loop through the list calling CalculateArea and CalculatePerimeter
The output should display the Object Type (Circle, Square or Triangle) the values used to initialize the shape, the area, and the perimeter

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!