Menu

[Solved] Objects Classes Topic Rectangle Class Following Example Code Circle Class Section 92 Desig Q37211840

thank you in advance!
Objects and Classes Topic: The Rectangle class Following the example code of the Circle class in Section 9.2, design a classObjects and Classes Topic: The Rectangle class Following the example code of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and length that specify the width and length of the rectangle. The default values are 0.0 for both width and length. A no-arg constructor that creates a default rectangle A constructor that creates a rectangle with the specified width and length A method named getArea) that returns the area of this rectangle. A method named getPerimeter) that returns the perimeter Accessor and Mutator methods for length and width Draw the UML diagram for the class and then implement the class. Make sure that your constructors and mutator methods can check the new length and width to make sure only positive values can be used in your rectangle objects, otherwise print out error message to the user Create your own project in Eclipse, add a test class with main method as usual first. Then add another new class called Rectangle without the main method in the same project. Now you sbould have two class files in your project. Implement the Rectangle class first. In your test class main method, creates two Rectangle objects one with width 4 and length 40 and the other with width 3.5 and length 35.9. Display the width, length, area, and perimeter of each rectangle in this order Bonus: Please add a class called Cube to present a cube to your project. The class contains: Three private double variables, length, width, and height A no-arg constructor that creates a default cube . A constractor with three parameters that creates a cube with specific length, width, and height The accessors and matators methods .A method to compute the area of the cube define at least two cube objects in your test program and use all the methods that you define in your Cube class. Show transcribed image text Objects and Classes Topic: The Rectangle class Following the example code of the Circle class in Section 9.2, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and length that specify the width and length of the rectangle. The default values are 0.0 for both width and length. A no-arg constructor that creates a default rectangle A constructor that creates a rectangle with the specified width and length A method named getArea) that returns the area of this rectangle. A method named getPerimeter) that returns the perimeter Accessor and Mutator methods for length and width Draw the UML diagram for the class and then implement the class. Make sure that your constructors and mutator methods can check the new length and width to make sure only positive values can be used in your rectangle objects, otherwise print out error message to the user Create your own project in Eclipse, add a test class with main method as usual first. Then add another new class called Rectangle without the main method in the same project. Now you sbould have two class files in your project. Implement the Rectangle class first. In your test class main method, creates two Rectangle objects one with width 4 and length 40 and the other with width 3.5 and length 35.9. Display the width, length, area, and perimeter of each rectangle in this order Bonus: Please add a class called Cube to present a cube to your project. The class contains: Three private double variables, length, width, and height A no-arg constructor that creates a default cube . A constractor with three parameters that creates a cube with specific length, width, and height The accessors and matators methods .A method to compute the area of the cube define at least two cube objects in your test program and use all the methods that you define in your Cube class.

Expert Answer


Answer to Objects and Classes Topic: The Rectangle class Following the example code of the Circle class in Section 9.2, design a c… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *