My Assignment: Write a class named Rectangle to represent rectangles. The data fields are width, height, and color. Use double for width and height, and String for color. Suppose that all the rectangles are the same color. You need to provide the accessor methods for the properties and a findArea() method for computing the area of the rectangle.
Write a client program(test class) to test the class Rectangle. In the client program, create two Rectangle objects. Assign any width and height to the two objects. Assign the first object the color red, and the second, yellow. Display the properties of both objects and find their areas.
Some of the codes of the main class rectangle were already provided by my instructor. I did the rest but still getting the main method not found error.
public class Rectangle { private double width = 1; private double height = 1; private static String color = "white"; public Rectangle( ) { } public Rectangle ( double widthParam, double heightParam, String colorParam ) { } public double getWidth ( ) { return width; } public void setWidth ( double widthParam ) { if ((width >= 0) || (width <0)) { System.out.println("Fatal error"); System.exit(0); } else { this.width = width; } } public double getHeight ( ) { return height; } public void setHeight ( double heightParam ) { if ((height >= 0) || (height <0)) { System.out.println("Fatal error"); System.exit(0); } else { this.height = height; }} public String getColor ( ) { return color; } public void setColor ( String colorParam ) { } public double findArea ( ) { double area = width * height; return area; } @Override public String toString ( ) { return ("Deafult height " + height + "Default width " + width + "Default color " + color); } } class Test{ public static void main(String[] args){ //invoking no-arg constructor Rectangle mr = new Rectangle(); mr.setHeight(2.0); mr.setWidth(3.0); double area1 = mr.findArea(); //invoking parameterized constructor Rectangle mr2 = new Rectangle(2.0,3.0,"yellow"); double area2=mr.findArea(); //printing areas System.out.println(area1); System.out.println(area1); } }