实验八 接口
作者:互联网
package 实验包; public class interface_test { public static void main (String[] arges){ yuanzhui a=new yuanzhui(2,5,6); yuanzhui b=new yuanzhui(1,3,3); System.out.println(a.Area()); System.out.println(b.Area()); System.out.println(a.volume()); System.out.println(b.volume()); System.out.println("体积较大的是:"+Math.max(a.volume(), b.volume())); } } class yuanzhui implements Volume,Area{ protected double r; protected double l; protected double h; public yuanzhui(double r,double l,double h){ this.r=r; this.l=l; this.h=h; } public double volume(){ return Math.PI*Math.pow(r,2)*h/3; } public double Area(){ return Math.PI*this.r*this.r+this.r*this.l; } } interface Volume{ public double volume(); } interface Area{ public double Area(); }
心得体会
不太会做这个实验,在同学的帮助下完成
以后会提前交作业,发誓不会再这么晚交。
标签:Area,double,yuanzhui,System,接口,volume,实验,public 来源: https://www.cnblogs.com/zyl9/p/10896977.html