Replace
Quote:
public class Square extends Rectangle{
Square s = new Square(50d);
double area = s.area();
double perimeter = s.perimeter();
}
public class Main
{
public static void main(String[] args) {
width = 10;
length = 25;
Shapes Rectangle = new Rectangle (width, length);
System.out.println("The area of the rectangle is: " + Rectangle.area());
}
}
with
class Square extends Rectangle
{
public Square(int a){ super(a,a); }
}
public class Main
{
public static void main(String[] args)
{
int width = 10;
int length = 25;
Shapes rectangle = new Rectangle (width, length);
Shapes square = new Square(width);
System.out.println("The area of the rectangle is: " + rectangle.area());
System.out.println("The area of the square is: " + square.area());
int a = 12;
int b = 20;
int c = 15;
Shapes triangle = new Triangle(a,b,c);
System.out.println("The area of the triangle is: " + triangle.area());
System.out.println("The perimeter of the triangle is: " + triangle.perimeter());
}
}