实验8

package paixu;
public class yuanzhuiti implements Area,tiji{
 double r;
 double h;
 private double length;
 public yuanzhuiti(double r,double h,double l) {
  this.r=r;
  this.h=h;
  length=l;
 }
@Override
public double result1() {
 double result=0.0;
 result=r*r*h*3.14*1/3;
 return result;
}
@Override
public double result() {
 return Math.PI*r*this.length+Math.PI*r*r;
}
public static void main(String[] args) {
 yuanzhuiti p=new yuanzhuiti(1,2,2);
 yuanzhuiti o=new yuanzhuiti(2,2,2);
   if(bijiao(p,o)) {
    System.out.println("p面积"+p.result()+"体积"+p.result1());
    System.out.println("o面积"+o.result()+"体积"+o.result1());
    System.out.println("p>o");
   }
   else {
    System.out.println("p面积"+p.result()+"体积"+p.result1());
    System.out.println("o面积"+o.result()+"体积"+o.result1());
    System.out.println("o>p");
   }
}
public static boolean bijiao(yuanzhuiti p,yuanzhuiti o) {
 if(p.result1()>o.result1()) {
  return true;
 }
 return  false;}
}
 
 
package paixu;
public interface Area {
double result();
}
 
 
 
package paixu;
public interface tiji {
double result1();
}
 
 
 
posted @ 2019-05-19 11:59  嘿嘿嘿😱  阅读(118)  评论(1编辑  收藏  举报