Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Shape {
- //protected int x, y;
- public String color;
- public abstract double computeArea( );
- }
- ------------------
- public class Rectangle extends Shape {
- double width, height;
- public Rectangle(double width, double height, String color) {
- this.width = width;
- this.height = height;
- super.color = color; <-------------------------------------
- }
- public double computeArea( ) {
- return width * height;
- }
- }
- ------------
- public class Circle extends Shape {
- double radius;
- public Circle(double radius) {
- this.radius = radius;
- }
- public double computeArea( ) {
- return Math.PI * radius * radius;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement