王梦然

例题4-10/4-11

class People{
 double getArea(double x,int y){
  return x*y;
 }
 int getArea(int x,double y){
  return (int)(x*y);
 }
 double getArea(float x,float y,float z){
  return(x*x+y*y+z*z)*2.0;
 }
}
public class Example4_10{
   public static void main(String args[]){
    People zhang=new People();
    System.out.println("面积:"+zhang.getArea(10,3.88));
    System.out.println("面积:"+zhang.getArea(10,0.8));
   }
  }

public class Tom{
 int leg;
 Tom(int n){
  this.cry();
  leg=n;
  this.cry();
 }
 void cry(){
  System.out.println("我是Tom,我现在有"+leg+"条腿");
 }
 public static void main(String args[]){
  Tom cat=new Tom(4);
 }

posted on 2013-04-14 19:23  快乐的铲屎官  阅读(146)  评论(0编辑  收藏  举报

导航