Question: just do this Part B-2: Add a Rectangle class to the Graphics project. The Rectangle class should derive from Shape. Add 2 int fields with

just do this Part B-2: Add a Rectangle class to the Graphics project. The Rectangle class should derive from Shape. Add 2 int fields with getters/setters: width and height. Add 1 vector field: lines. Add 1 constructor with the following parameters: width, height, startPt, color. Pass the startPt and color to the base constructor. Use width and height to set the properties. The constructor should create 4 Lines and add them to the lines field. The 4 Lines: top left to top right top right to bottom right bottom left to bottom right top left to bottom left Override the draw method of the Shape class (that means you need to mark the base as virtual). Do not call the base. Instead, call the draw method of each Line in the lines list. In Main, add code to case 3 of the menu switch. Generate a random Point2D point with an x,y anywhere in the console. This point will be the top-left position of the Rectangle. Calculate a random width and height - ensure that it will NOT extend the Rectangle beyond the bounds of the console. Use the point, width, and height to create a Rectangle instance with any color you want. Call draw on the Rectangle instance

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets walk through the implementation step by step for adding a Rectangle class to the existing Graphics project Assuming we have a Shape class and a Line class already defined I will guide you on how ... View full answer

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 Algorithms Questions!