/** * Called by busses belonging to this system every time the bus has stopped. It calls every * passengers enterBus() method so that the passengers can enter the bus if they want to. * * @param busID Unique identifier of the bus * @param busStop Coordinates of the bus stop * @param nextPath The path to the next stop */ public void busHasStopped(int busID, Coord busStop, Path nextPath) { Iterator<BusTravellerMovement> iterator = travellers.values().iterator(); while (iterator.hasNext()) { BusTravellerMovement traveller = (BusTravellerMovement) iterator.next(); if (traveller.getLocation() != null) { if ((traveller.getLocation()).equals(busStop)) { if (traveller.getState() == BusTravellerMovement.STATE_WAITING_FOR_BUS) { Path path = new Path(nextPath); traveller.enterBus(path); } } } } }
/** * Registers a traveller/passenger to be part of a bus control system * * @param traveller The traveller to register */ public void registerTraveller(BusTravellerMovement traveller) { travellers.put(traveller.getID(), traveller); }