//卖水果:10元/千克 public override int Sell(ref int money) { if (orchardist == null) orchardist = new Orchardist(); int fruit = money / 10; //卖出的水果数量 //如果水果总量不足则向果农购买水果 if (fruit > this.fruit) this.fruit += this.orchardist.Sell(ref this.money) * 1000; this.fruit -= fruit; //代理商卖出的水果 this.money += fruit * 10; //代理商的收入 money -= fruit * 10; //购买者支出金额 Console.WriteLine("代理商卖出水果{0}千克,还剩{1}千克水果,收入{2}元!", fruit, this.fruit, fruit * 10); return fruit; //卖出的水果数量 }
//卖水果:10元/千克 public override int Sell(ref int money) { if (orchardist == null) orchardist = new Orchardist(); int fruit = money / 10; //卖出的水果数量 //如果水果总量不足则向果农购买水果 if (fruit > this.fruit) this.fruit += this.orchardist.Sell(ref this.money) * 1000; this.fruit -= fruit; //代理商卖出的水果 this.money += fruit * 10; //代理商的收入 money -= fruit * 10; //购买者支出金额 Console.WriteLine("代理商卖出水果{0}千克,还剩{1}千克水果,收入{2}元!", fruit, this.fruit, fruit * 10); return fruit; //卖出的水果数量 }