Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a constructor to initialize the instance variables, several methods
Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a constructor to initialize the instance variables, several methods to access and update the instance variables' values, along with other methods to perform calculations. Also, write a test class that instantiates the first class and tests the class's constructor and methods. Details: Create a class called Rectangle containing the following: . Two instance variables, An instance variable of type double used to hold the rectangle's width. o An instance variable of type double used to hold the rectangle's height. Provide a constructor with two parameters used to initializes each instance variable. The constructor should verify that the specified width and height values are greater than 0.0 and less than or equal to 20.0. If they are not, indicate an exception has occurred. Provide get methods that return the values of each instance variables. Provide set methods that set the instance variables to new values. The methods should also verify that the specified width and height values are greater than 0.0 and less than or equal to 20.0. If they are not, indicate an exception has occurred. Provide a method called calculatePerimeter that calculates the perimeter of the rectangle and return that value as a double. Provide a method called calculateArea that calculates the area of the rectangle and returns that value as a double. Create a second class called Rectangle Test that contains the main method, and thoroughly tests the Rectangle class's methods. This test class does not need to ask users for input. Just create the needed Rectangle objects to ensure that you test the Rectangle class's methods well. The thoroughness of your testing in will impact your grade. Upload both source files to Blackboard. Note: Ensure that your program is properly formatted and it follows all Java naming conventions. AIT 500 - Programming Assignment (Michael Boehmer)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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