例4-10和例4-11和例4-12

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);
 }
}

 

package tom.jiafei;
class Tom{
 void speak(){
   System.out.println("Tom类在tom.jiafei包中");
  }
 }


 public class Example4_12{
  public static void main(String args[]){
   Tom cat=new Tom();
   cat.speak();
   System.out.println("Example4_12类也在tom.jiafei包中");
  }
 }
  
 

posted @ 2013-03-22 22:42  张欣博同学  阅读(134)  评论(0编辑  收藏  举报