/* * Copyright 2010 Aalto University, ComNet * Released under GPLv3. See LICENSE.txt for details. */ package movement; import core.Coord; import core.SimError; /** * A class to encapsulate information about a shopping trip * 1. Where the trip begins * 2. Where it ends * 3. The path * 4. All nodes in the group * * @author Frans Ekman */ public class EveningTrip { private EveningActivityMovement[] eveningActivityNodes; private int eveningActivityNodesInBuffer; private int eveningActivityNodesExpected; private Path path; private Coord location; private Coord destination; private double waitTimeAtEnd; /** * Create a new instance of a EveningTrip * @param nrOfeveningActivityNodes The number of shoppers in the group * @param location Where the trip starts */ public EveningTrip(int nrOfeveningActivityNodes, Coord location) { eveningActivityNodes = new EveningActivityMovement[nrOfeveningActivityNodes]; this.location = location; eveningActivityNodesInBuffer = 0; eveningActivityNodesExpected = nrOfeveningActivityNodes; } /** * Add an evening activity node to the group * @param eveningActivityNode * @return true if there was room in the group */ public boolean addNode(EveningActivityMovement eveningActivityNode) { if (isFull()) { return false; } else { eveningActivityNodes[eveningActivityNodesInBuffer] = eveningActivityNode; eveningActivityNodesInBuffer++; return true; } } /** * Sets the shopping path for the group * @param path */ public void setPath(Path path) { this.path = new Path(path); } /** * @return The shopping trip path */ public Path getPath() { if (path != null) { return new Path(this.path); } else { return null; } } /** * @return The location where the shopping trip starts */ public Coord getLocation() { return location; } /** * @return true if the group is full */ public boolean isFull() { return eveningActivityNodesInBuffer >= eveningActivityNodesExpected; } /** * Checks if all members of the group have found their way to the meeting * point * @return true if all nodes are there */ public boolean allMembersPresent() { if (!isFull()) { return false; } for (int i=0; i