Class AggregatedBuyTradeStep

  • All Implemented Interfaces:
    ITradeStep

    public class AggregatedBuyTradeStep
    extends java.lang.Object
    implements ITradeStep
    Trade step aggregating several wares to buy.
    • Field Detail

      • city

        private ICity city
      • executeNext

        private boolean executeNext
      • context

        @Autowired
        private org.springframework.context.ApplicationContext context
      • tradeSteps

        private java.util.ArrayList<BuyTradeStep> tradeSteps
      • retainCash

        private long retainCash
    • Constructor Detail

      • AggregatedBuyTradeStep

        public AggregatedBuyTradeStep()
    • Method Detail

      • addBuyStep

        public void addBuyStep​(IWare ware,
                               int maxPrice)
      • getPriorityList

        private java.util.List<BuyTradeStep> getPriorityList()
        Sort the list of wares that should be bought so that the wares with the least amount are at the begining of the list.
        Returns:
        priority sorted ware list.
      • execute

        public boolean execute()
        Description copied from interface: ITradeStep
        Execute the trade step.
        Specified by:
        execute in interface ITradeStep
        Returns:
        true if the next step can be executed on completion or if the execution is triggered by the arrival of the ship in the next port.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object