dengyinjun
发贴: 11
积分: 0
|
于 2005-05-25 03:54
interface class Shape{ double area();{ } double perimeter(){ } } class Rectangle implements Shape{ int width,height; Rectangle(double width,double length){ this.width = width; this.height = height; } public double area();{ return width*height; } public double perimeter(){ return 2*(width+height); } } class Test { public static void main(String[] args){ Shape shape = new Rectangle(4,5); System.out.println(""+shape.area()); System.out.println(""+shape.perimeter()); } }
dengyinjun edited on 2005-05-25 03:56
|