太原理工大学软件java实验报告(16)
发布时间:2021-06-12
发布时间:2021-06-12
{
for (int i = 0; i < goodsList.size(); i++) {
Goods goods_2 = goodsList.get(i);
if (goods_2.getName().equals(goods.getName())) {
if (goods.getNumber()>goods_2.getNumber()) {
flag+=" 原因:库存不足"; }
else if ((goods_2.getPrice()*goods.getNumber()) > goods.getPrice()) {
flag+=" 原因:余额不足"; } else {
goods_2.setNumber(goods_2.getNumber()-goods.getNumber()); flag = "销售商品["+goods.getName()+"]成功"; } break; } } }
return flag; } /** * 查询商品 * @return */
public List<Goods> getGoodsList() {
return goodsList; }
public void setGoodsList(List<Goods> goodsList) {
this.goodsList = goodsList; } }
上一篇:宜春一对一辅导机构哪家好