1700466861
1700466862
}
1700466863
1700466864
//得到项目的信息
1700466865
1700466866
public String getProjectInfo(){
1700466867
1700466868
String info=””;
1700466869
1700466870
//获得项目的名称
1700466871
1700466872
info=info+“项目名称是:”+this.name;
1700466873
1700466874
//获得项目人数
1700466875
1700466876
info=info+”\t项目人数:”+this.num;
1700466877
1700466878
//项目费用
1700466879
1700466880
info=info+”\t项目费用:”+this.cost;
1700466881
1700466882
return info;
1700466883
1700466884
}
1700466885
1700466886
}
1700466887
1700466888
实现类也是极度简单,通过构造函数把要显示的数据传递过来,然后放到getProjectInfo中显示,这太容易了!然后我们老大要看看结果了,如代码清单20-3所示。
1700466889
1700466890
代码清单20-3 老大看报表的场景
1700466891
1700466892
public class Boss{
1700466893
1700466894
public static void main(String[]args){
1700466895
1700466896
//定义一个List,存放所有的项目对象
1700466897
1700466898
ArrayList<IProject>projectList=new ArrayList<IProject>();
1700466899
1700466900
//增加星球大战项目
1700466901
1700466902
projectList.add(new Project(“星球大战项目”,10,100000));
1700466903
1700466904
//增加扭转时空项目
1700466905
1700466906
projectList.add(new Project(“扭转时空项目”,100,10000000));
1700466907
1700466908
//增加超人改造项目
1700466909
1700466910
projectList.add(new Project(“超人改造项目”,10000,1000000000));
[
上一页 ]
[ :1.700466861e+09 ]
[
下一页 ]