public class Bean {
String name;
private String place="SHA_airport CN";
private String thing="playing";
public Bean(String name){
this.name=name;
}
public void setPlace(String place){
this.place=place;
}
public void setThing(String thing){
this.thing=thing;
}
public String getBeanState(){
return new String(name+" is "+thing+" at "+place+".");
}
}
public class BeanGroup {
private Bean[] beans={new Bean("wasabiBean"),
new Bean("thunderclapBean"),
new Bean("javaBean"),
new Bean("bobbyBean")};
public BeanGroup(){
beans[0].setPlace("Melbourne AU");
beans[0].setThing("training");
beans[1].setPlace("SH_SHA CN");
beans[1].setThing("working");
beans[2].setPlace("SH_zhangjiang CN");
beans[2].setThing("spying");
beans[3].setPlace("SH_PVG CN");
beans[3].setThing("on duty");
}
public void printBeanGroupState(){
for(int i=0; i<beans.length; i++){
System.out.println(beans[i].getBeanState());
}
}
public static void main(String[] args){
new BeanGroup().printBeanGroupState();
}
}
No comments:
Post a Comment