1700475834
代码清单29-14 服装
1700475835
1700475836
public class Clothes extends Product{
1700475837
1700475838
public void beProducted(){
1700475839
1700475840
System.out.println(“生产出的衣服是这样的……”);
1700475841
1700475842
}
1700475843
1700475844
public void beSelled(){
1700475845
1700475846
System.out.println(“生产出的衣服卖出去了……”);
1700475847
1700475848
}
1700475849
1700475850
}
1700475851
1700475852
然后再稍稍修改一下场景类,如代码清单29-15所示。
1700475853
1700475854
代码清单29-15 场景类
1700475855
1700475856
public class Client{
1700475857
1700475858
public static void main(String[]args){
1700475859
1700475860
House house=new House();
1700475861
1700475862
System.out.println(”––-房地产公司是这样运行的––-“);
1700475863
1700475864
//先找到房地产公司
1700475865
1700475866
HouseCorp houseCorp=new HouseCorp(house);
1700475867
1700475868
//看我怎么挣钱
1700475869
1700475870
houseCorp.makeMoney();
1700475871
1700475872
System.out.println(”\n”);
1700475873
1700475874
//山寨公司生产的产品很多,不过我只要指定产品就成了
1700475875
1700475876
System.out.println(”––-山寨公司是这样运行的––-“);
1700475877
1700475878
ShanZhaiCorp shanZhaiCorp=new ShanZhaiCorp(new Clothes());
1700475879
1700475880
shanZhaiCorp.makeMoney();
1700475881
1700475882
}
1700475883
[
上一页 ]
[ :1.700475834e+09 ]
[
下一页 ]