标签:java
/**7
* 編寫一個可以計算面積和體積的接口,
* 以及實現這個接口的四邊形類
* (包括矩形,平行四邊形、梯形)
**/
public class Test{ public static void main(String[] args){ } } interface Figure{ double Area(double a, double b); double Volume(double a, double b, double c); } class Rectangle implements Figure{ private double a, b, c; public double Area(double a, double b) { this.a = a; this.b = b; return (a * b); } public double Volume(double a, double b, double c) { this.a = a; this.b = b; this.c = c; return a * b * c; } } class parallelogram implements Figure{ private double a, b, c; public double Area(double a, double b) { this.a = a; this.b = b; return (a * b); } public double Volume(double a, double b, double c) { this.a = a; this.b = b; this.c = c; return a * b * c; } }
本文出自 “hacker” 博客,请务必保留此出处http://anglecode.blog.51cto.com/5628271/1619891
标签:java
原文地址:http://anglecode.blog.51cto.com/5628271/1619891