The purpose of this lab is to give you practice creating your own object. You will be given a class that expects an instance of the (yet undefined) Rectangle object.
Your job is to determine what attributes and methods the Rectangle class requires and create a class that will satisfy the requirements.
You can begin with this RecDemo class:
// Use this class to test your own Rectangle class
public class RecDemo {
/**
* @param args
*/
public static void main(String[] args) {
// You can't substantially change this code.
// Write your Rectangle class so the following
// code will work correctly.
Rectangle myRec;
myRec = new Rectangle(5d, 3d);
System.out.println(myRec.getValues());
myRec = new Rectangle();
System.out.println(myRec.getValues());
myRec = new Rectangle(Rectangle.SMALL);
System.out.println(myRec.getValues());
myRec = new Rectangle(Rectangle.MEDIUM);
System.out.println(myRec.getValues());
myRec = new Rectangle(Rectangle.LARGE);
System.out.println(myRec.getValues());
System.out.println(Rectangle.calcPerimeter(5d, 6d));
System.out.println(Rectangle.calcArea(5d, 6d));
} // end main
} // end RecDemo
Please begin by copying this code into your editor, then creating a Rectangle class that can satisfy the requirements.
When the Rectangle class has been properly created, the output should look like the following:
width: 5.0, height: 3.0, area: 15.0, perimeter: 16.0
width: 5.0, height: 10.0, area: 50.0, perimeter: 30.0
width: 2.0, height: 3.0, area: 6.0, perimeter: 10.0
width: 5.0, height: 10.0, area: 50.0, perimeter: 30.0
width: 10.0, height: 15.0, area: 150.0, perimeter: 50.0
22.0
30.0
Add a Graphic Interface to the project. Use labels to print out all the output. Additionally, add text fields for height and width, and calculate the area and perimeter using your class.