1700462160
库房中的货物数量肯定有增减,同时库房还有一个容量显示,达到一定的容量后就要求对一些商品进行折价处理,以腾出更多的空间容纳新产品。于是就有了clearStock方法,既然是清仓处理肯定就要折价销售了。于是在Sale类中就有了offSale方法,我们来看Sale源代码,如代码清单14-3所示。
1700462161
1700462162
代码清单14-3 销售管理
1700462163
1700462164
public class Sale{
1700462165
1700462166
//销售IBM电脑
1700462167
1700462168
public void sellIBMComputer(int number){
1700462169
1700462170
//访问库存
1700462171
1700462172
Stock stock=new Stock();
1700462173
1700462174
//访问采购
1700462175
1700462176
Purchase purchase=new Purchase();
1700462177
1700462178
if(stock.getStockNumber()<number){//库存数量不够销售
1700462179
1700462180
purchase.buyIBMcomputer(number);
1700462181
1700462182
}
1700462183
1700462184
System.out.println(“销售IBM电脑”+number+“台”);
1700462185
1700462186
stock.decrease(number);
1700462187
1700462188
}
1700462189
1700462190
//反馈销售情况,0~100之间变化,0代表根本就没人卖,100代表非常畅销,出一个卖一个
1700462191
1700462192
public int getSaleStatus(){
1700462193
1700462194
Random rand=new Random(System.currentTimeMillis());
1700462195
1700462196
int saleStatus=rand.nextInt(100);
1700462197
1700462198
System.out.println(“IBM电脑的销售情况为:”+saleStatus);
1700462199
1700462200
return saleStatus;
1700462201
1700462202
}
1700462203
1700462204
//折价处理
1700462205
1700462206
public void offSale(){
1700462207
1700462208
//库房有多少卖多少
1700462209
[
上一页 ]
[ :1.70046216e+09 ]
[
下一页 ]