Basically have to do this assignment for class and need some help.
Program a class for each of the following 2D shapes:
Circle
Triangle
Rectangle
Trapezoid
Each 2D shape class must have the following:
Your Main class should have the following:
Program a class for each of the following 2D shapes:
Circle
Triangle
Rectangle
Trapezoid
Each 2D shape class must have the following:
- Appropriate instance variables that are all set to private. (i.e. length, width, area, etc.)
One static variable that holds the number of instantiated objects of the class.
Use of the this keyword in constructors/methods when dealing with a class' instance variables.
Overloaded constructors, except for the Circle class. For example...
Code
Rectangle(double length)
Rectangle(double length, double width)- One private void method that calculates circumference/perimeter. For example...
Code
private void calculatePerimeter()- One private void method that calculates area. For example...
Code
private void calculateArea()- Public getter methods for each private variable. For example...
Code
public double getLength()- Overloaded public setter methods in the same manner as the constructors. For example...
Code
public void setRectangle(double length)
public void setRectangle(double length, double width)- One public print method to print out all its instance variables. For example...
Code
public void print()Your Main class should have the following:
- Declaration of two instances of each class, each initialized with different values.
- Printout of each instance using their print methods.
- A resetting of each instance using their setter methods, giving them different values.
- Another printout of each instance using their print methods.



