Hello! I am working my way through this problem for my Introduction to Java Programming Course. I think I understand the majority of it but I am have a very hard time understanding and developing the bounding box methods. I have developed the Point, Shape, Rectangle, Triangle and Circle classes but I am lost on how to calculate the bounding box coordinates for each of the hierarchy shapes. If someone would be kind enough to walk me through and explain this program, I would greatly appreciate it. Thank you kindly! Problem #5: Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Hint: Keep x and y separate in the calculation. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points) of a rectangle that encloses the shape (a bounding box). These will be overloaded by the derived classes; therefore, the default methods for Shape will only print a simple message to standard output. Create a display() function for Shape, which will display the name of the class and all stored information about the class (including area, circumference and bounding box). Build the hierarchy by creating the Shape classes Circle, Rectangle and Triangle. Search the Internet for the rules governing these shapes, if necessary. For these three Shape classes, create default constructors, as well as constructors whose arguments will initialize the shapes appropriately using the correct number of Point objects (i.e., Circle requires a Point center and a radius; Rectangle requires four Point vertices; and Triangle requires three Point vertices). Add error-checking to the constructors, such that they print a warning if the arguments do not conform to the appropriate shape. Hint: Not all four-sided shapes are rectangles. Also add a check to Rectangle, such that it tests for the special case of a “square” and prints an appropriate message if the test is true. In main(), create several instances of each shape object and display the information for each object. Be sure to create at least one non-rectangle shape to demonstrate your error handling, and at least one square.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello! I am working my way through this problem for my Introduction to Java Programming Course. I think I understand the majority of it but I am have a very hard time understanding and developing the bounding box methods. I have developed the Point, Shape, Rectangle, Triangle and Circle classes but I am lost on how to calculate the bounding box coordinates for each of the hierarchy shapes. If someone would be kind enough to walk me through and explain this program, I would greatly appreciate it. Thank you kindly!

Problem #5:

Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates.

Hint: Keep x and y separate in the calculation.

Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points) of a rectangle that encloses the shape (a bounding box). These will be overloaded by the derived classes; therefore, the default methods for Shape will only print a simple message to standard output.

Create a display() function for Shape, which will display the name of the class and all stored information about the class (including area, circumference and bounding box).

Build the hierarchy by creating the Shape classes CircleRectangle and Triangle. Search the Internet for the rules governing these shapes, if necessary.

For these three Shape classes, create default constructors, as well as constructors whose arguments will initialize the shapes appropriately using the correct number of Point objects (i.e., Circle requires a Point center and a radius; Rectangle requires four Point vertices; and Triangle requires three Point vertices). Add error-checking to the constructors, such that they print a warning if the arguments do not conform to the appropriate shape.

Hint: Not all four-sided shapes are rectangles.

Also add a check to Rectangle, such that it tests for the special case of a “square” and prints an appropriate message if the test is true.

In main(), create several instances of each shape object and display the information for each object. Be sure to create at least one non-rectangle shape to demonstrate your error handling, and at least one square.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY