public void Down(Wagon wagon, IMerchandise merchandise) { if (this.MerchantMode.Equals(TraderMode.Sell)) { var percentageWithOutMerchandise = this.CurrentPercentage - (merchandise.GetWeight() * 100 / this.MaxTransportWeight); if (percentageWithOutMerchandise >= this.PercentageToEmpty) { this.CurrentPercentage = percentageWithOutMerchandise; wagon.Merchandise.Remove(merchandise); } } }
public void Up(Wagon wagon, IMerchandise merchandise) { if (merchandise.GetWeight() < this.PackageMaxWeight) { wagon.Merchandise.Add(merchandise); } else if (!this.IsOverweightPackage) { this.IsOverweightPackage = true; wagon.Merchandise.Add(merchandise); } }
public void Up(Wagon wagon, IMerchandise merchandise) { if (this.MerchantMode.Equals(TraderMode.Buy)) { var percentageWithMerchandise = this.CurrentPercentage + (merchandise.GetWeight() * 100 / this.MaxTransportWeight); if (percentageWithMerchandise <= this.PercentageToFill) { this.CurrentPercentage = percentageWithMerchandise; wagon.Merchandise.Add(merchandise); } } }
public bool IsThereSpace(IMerchandise merchandise) { return((WeightCarried + merchandise.GetWeight()) < TotalWeight); }
public bool HaveIt(IMerchandise merchandise) { return(this.Merchandise.Any(x => x.GetWeight() == merchandise.GetWeight())); }
public void Down(Wagon wagon, IMerchandise merchandise) { if (this.IsOverweightPackage) { this.IsOverweightPackage = false; } wagon.Merchandise.RemoveAt(wagon.Merchandise.FindIndex(x => x.GetWeight() == merchandise.GetWeight())); }
public void Up(Wagon wagon, IMerchandise merchandise) { wagon.WeightCarried += merchandise.GetWeight(); wagon.Merchandise.Add(merchandise); }
void ITradePolicy.Down(Wagon wagon, IMerchandise merchandise) { wagon.WeightCarried -= merchandise.GetWeight(); wagon.Merchandise.Remove(merchandise); }