Last active
May 30, 2022 17:15
-
-
Save mcsee/9f0082db40c2ab590b2b6ea9702bbb22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract public class Shape{ | |
abstract public int area(); | |
} | |
public final class Rectangle extends Shape { | |
int length; | |
int width; | |
public Rectangle(int length, int width) { | |
length = length; | |
width = width; | |
} | |
public int area() { | |
return length * width; | |
} | |
} | |
public final class Square extends Shape { | |
int size; | |
public Square(int size) { | |
size = size; | |
} | |
public int area() { | |
return size * size; | |
} | |
} | |
public final class Box { | |
Square shape; | |
public Box(int size) { | |
shape = new Square(size); | |
} | |
public int area() { | |
return shape.area(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment