实训第一天

1.面向对象

一句话分开,分成几个对象,然后用类实现

public static void main(String args[]){

animal a = new animal();

a.show();

}

public class animal{

private String name;

private int age;

public String getName() {
    return name;
}



public void setName(String name) {
    this.name = name;
}



public int getLeg() {
    return leg;
}



public void setLeg(int leg) {
    this.leg = leg;
}

public void show(){

System.out.println(setname+" "+setage);

}

public aninal(){}

public animal(String name,int age){

this.name=name;

this.age=age;

}

}

 

 

 

2.接口,和借口的实现

public interface DouphinService{

public void call();

 

 

}

public class DouphinServiceimpl implements DouphinService{

public void call(){

System.out.println("haitunyin");

}

}

posted on 2017-11-14 22:58  JETIME庚  阅读(148)  评论(0编辑  收藏  举报

导航