Write a program that creates a ‘shape calculator’. There must be: Shape, Circle, Rectangle, and Triangle classes. There should also be a Point class. Set up proper protection. You need to set up the inheritance. Each class must be in a separate file. Circle, Rectangle and Triangle must have methods that calculate area and perimeter. There should be at least one constructor that fills all the Point (and radius) attributes for Circle (1 Point), Rectangle (2 Points) and Triangle (3 Points). Overload the add operator to add areas of like objects (2 circles, 2 rectangles, 2 triangles) for each child class. If the circle or rectangle or triangle does not exist, an error should be thrown and caught and a message should be made to your output screen. A looping menu should be made to offer the user to create the shapes, get the area and perimeter and enter a point for the circle/rectangle/triangle. All shapes should have double attributes. Circle should have a radius and center point. A rectangle should two points. A triangle should have three points. To calculate area of a triangle based on the three sides: Area=sqrt(p(p-a)(p-b)(p-c)) where a, b, c are the lengths of the sides of a triangle and p is half the perimeter, or (a+b+c)/2.
C# question using inheritance:
Write a program that creates a ‘shape calculator’. There must be: Shape, Circle, Rectangle, and Triangle classes. There should also be a Point class. Set up proper protection. You need to set up the inheritance. Each class must be in a separate file. Circle, Rectangle and Triangle must have methods that calculate area and perimeter. There should be at least one constructor that fills all the Point (and radius) attributes for Circle (1 Point), Rectangle (2 Points) and Triangle (3 Points). Overload the add operator
to add areas of like objects (2 circles, 2 rectangles, 2 triangles) for each child class. If the circle or rectangle or triangle does not exist, an error should be thrown and caught and a message should be made to your output screen. A looping menu should be made to offer the user to create the shapes, get the area and perimeter and enter a point for the circle/rectangle/triangle. All shapes should have double attributes. Circle should have a radius and center point. A rectangle should two points. A triangle should have three points.
To calculate area of a triangle based on the three sides:
Area=sqrt(p(p-a)(p-b)(p-c)) where a, b, c are the lengths of the sides of a triangle and p is half the perimeter, or (a+b+c)/2.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images