Question: Assignment Instructions: Create a Rectangle class with the following: 1. Must have 2 private attributes, width and height, both of type integer. 2. Must have

Assignment Instructions: Create a Rectangle class with the following: 1. Must have 2 private attributes, width and height, both of type integer. 2. Must have an overloaded constructor, which takes in 2 integer parameters and initializes the 2 private attributes. 3. Must have a getter and setter method for each of the 2 private attributes. 4. Must have a method, call it perimeter, which calculates a rectangle's perimeter, takes no parameters, and returns an integer. (Note: The perimeter of a rectangle is calculated by adding 2 height +2 width) 5. Must have a method, call it area, which calculates a rectangle's area, takes no parameters, and returns an integer. (Note: The area of a rectangle is calculated by multiplying the height by the width) Create a RectangleTest class (i.e., main class or driver class) that does the following: 1. Prompts the user for and reads in an integer value for the rectangle's width. 2. Prompts the user for and reads in an integer value for the rectangle's height. 3. Using values from steps 1 and 2 above, creates a rectangle object, call it rectangle_1. 4. Using only the methods in rectangle_1 (getter, setter, area, and perimeter) displays its width, height, area, and perimeter, with appropriate titles. 5. Using only the setter and getter methods in rectangle_1, changes its size by doubling its width and height values. 6. Using only the methods in rectangle_1 (getter, setter, area, and perimeter) displays its width, height, area, and perimeter, with appropriate titles. Note: Step 5 in the RectangleTest class must use only the setter and getter methods from rectangle_1. No credit will be given otherwise (i.e., you cannot use the values entered by the user in steps 1 and 2; you cannot create new calculations within the RectangleTest class; and you cannot create a new rectangle object or recreate the rectangle_1 object.) Submission Instructions: You must rename your .java files to .txt and submit the following items to the D2L dropbox before the deadline: 1. Rectangle.txt 2. RectangleTest.txt
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
