示例#1
0
 public virtual decimal Estimate(IMerchandise merchandise)
 {
     if (_exemptions.GetExemptions().Contains(merchandise.MerchandiseType))
     {
         return(0M);
     }
     return(Math.Round(merchandise.Price / 10M, 2, MidpointRounding.AwayFromZero));
 }
示例#2
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()));
        }
示例#3
0
        public virtual decimal Estimate(IMerchandise merchandise)
        {
            if (!merchandise.Import)
            {
                return(0M);
            }

            return(Math.Round(merchandise.Price / 20M, 1, MidpointRounding.AwayFromZero));
        }
示例#4
0
        public override bool IsValid(object value)
        {
            IMerchandise item = value as IMerchandise;

            if (item == null)
            {
                return(!Optional);
            }

            return(item.Item != null && item.QualityRange.Low <= item.QualityRange.High);
        }
示例#5
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);
         }
     }
 }
示例#6
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);
     }
 }
示例#7
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);
         }
     }
 }
示例#8
0
 public bool IsThereSpace(IMerchandise merchandise)
 {
     return((WeightCarried + merchandise.GetWeight()) < TotalWeight);
 }
示例#9
0
 public bool HaveIt(IMerchandise merchandise)
 {
     return(this.Merchandise.Any(x => x.GetWeight() == merchandise.GetWeight()));
 }
示例#10
0
 public void Down(IMerchandise merchandise)
 {
     TradePolicy.Down(this, merchandise);
 }
示例#11
0
 public void Up(IMerchandise merchandise)
 {
     TradePolicy.Up(this, merchandise);
 }
示例#12
0
 public virtual void Add(IMerchandise merchandise)
 {
     _goods.Add(merchandise);
 }
示例#13
0
 public void Bid(IMerchandise merchandise)
 {
     SupplyList.Add(merchandise);
 }
        private void PrintText(IMerchandise merchandise, decimal tax)
        {
            var priceTotal = merchandise.Price + tax;

            Console.WriteLine($"{merchandise.Amount} {merchandise.Name}: {priceTotal:####.#0}");
        }
示例#15
0
 public void Up(Wagon wagon, IMerchandise merchandise)
 {
     wagon.WeightCarried += merchandise.GetWeight();
     wagon.Merchandise.Add(merchandise);
 }
示例#16
0
 void ITradePolicy.Down(Wagon wagon, IMerchandise merchandise)
 {
     wagon.WeightCarried -= merchandise.GetWeight();
     wagon.Merchandise.Remove(merchandise);
 }
示例#17
0
 public void Demand(IMerchandise merchandise)
 {
     DemandList.Add(merchandise);
 }
示例#18
0
 public MerchandiseStock(IMerchandise item, int amount)
 {
     Item   = item;
     Amount = amount;
 }