Пример #1
0
 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);
         }
     }
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 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);
         }
     }
 }
Пример #4
0
 public bool IsThereSpace(IMerchandise merchandise)
 {
     return((WeightCarried + merchandise.GetWeight()) < TotalWeight);
 }
Пример #5
0
 public bool HaveIt(IMerchandise merchandise)
 {
     return(this.Merchandise.Any(x => x.GetWeight() == merchandise.GetWeight()));
 }
Пример #6
0
        public void Down(Wagon wagon, IMerchandise merchandise)
        {
            if (this.IsOverweightPackage)
            {
                this.IsOverweightPackage = false;
            }

            wagon.Merchandise.RemoveAt(wagon.Merchandise.FindIndex(x => x.GetWeight() == merchandise.GetWeight()));
        }
Пример #7
0
 public void Up(Wagon wagon, IMerchandise merchandise)
 {
     wagon.WeightCarried += merchandise.GetWeight();
     wagon.Merchandise.Add(merchandise);
 }
Пример #8
0
 void ITradePolicy.Down(Wagon wagon, IMerchandise merchandise)
 {
     wagon.WeightCarried -= merchandise.GetWeight();
     wagon.Merchandise.Remove(merchandise);
 }