Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface Shape
- {
- public abstract double area();
- }
- public class Circle implements Shape
- {
- private double radius;
- public Circle(double radius)
- {
- this.radius = radius;
- }
- public void setRadius(double radius)
- {
- this.radius = radius;
- }
- public double getRadius()
- {
- return radius;
- }
- public double area(double radius)
- {
- return getRadius()*getRadius()*3.14;
- }
- }
- public class Rectangle implements Shape
- {
- private double length;
- private double width;
- public void setLength(double length)
- {
- this.length = length;
- }
- public void setWidth(double width)
- {
- this.width = width;
- }
- public double getLength()
- {
- return length;
- }
- public double getWidth()
- {
- return width;
- }
- public double area()
- {
- return getLength()*getWidth();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement