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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

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.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT