Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
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 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started