Class Crewman

java.lang.Object
  |
  +--Job
        |
        +--Crewman
Direct Known Subclasses:
Navigator, Security

public abstract class Crewman
extends Job

Parent class the groups both Navigator and Security
Contains the methods that will be used by both


Field Summary
static int MAXPENDING
           
 
Fields inherited from class Job
ADMIRAL, CAPTAIN, ENGINEER, NAVIGATOR, SECURITY, titles
 
Constructor Summary
Crewman(int rank)
          Creates a new Crewman
 
Method Summary
 boolean completeOrder()
          Will complete the current order by removing the current order and assigning the next pending order.
 void executeSession(Person user)
          Prints the Crewman menu and then retrieves the user's input.
 Order getCurrentOrder()
          returns the Crewman's current order
 boolean giveOrder(Order newOrder)
          Method that assigns an order to the Crewman from a superior officer.
Things to note:
* If a Crewman has no current order, then the newOrder will become the Crewman's current order
* A Crewman can only accept certain orders, as defined by the possibleOrders[rank] array
* You MUST use the OrderIterator class to iterate through the pending orders
* Orders MUST be inserted into the pendingOrders array in order or Priority
* Example: A Crewman has 2 pending orders, 1 High and 1 Low.
 java.lang.String printPendingOrders()
          Returns a string of all the pending orders for the caller to print You MUST use an ObjectIterator to iterate through the pending orders
 boolean setSuperiorOfficer(Person officer)
          Sets the Crewman's Superior Officer.
 java.lang.String toString()
          Returns a string describing the Crewman class.
 
Methods inherited from class Job
getRank, issueOrder, whichOrders
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAXPENDING

public static final int MAXPENDING
See Also:
Constant Field Values
Constructor Detail

Crewman

public Crewman(int rank)
Creates a new Crewman

Parameters:
rank - - value given from the child class that defines which rank the instance is. Value is a constant that is referenced in Job.java
Method Detail

setSuperiorOfficer

public boolean setSuperiorOfficer(Person officer)
Sets the Crewman's Superior Officer. Only members of the Officer class can become a Superior Officer A Crewman can only have 1 Superior Officer

Parameters:
officer - - The officer that will become the user's Superior Officer
Returns:
true or false, depending on success

getCurrentOrder

public Order getCurrentOrder()
returns the Crewman's current order

Returns:
returns the Crewman's current order

giveOrder

public boolean giveOrder(Order newOrder)
Method that assigns an order to the Crewman from a superior officer.
Things to note:
* If a Crewman has no current order, then the newOrder will become the Crewman's current order
* A Crewman can only accept certain orders, as defined by the possibleOrders[rank] array
* You MUST use the OrderIterator class to iterate through the pending orders
* Orders MUST be inserted into the pendingOrders array in order or Priority
* Example: A Crewman has 2 pending orders, 1 High and 1 Low. If a superior officer assigns the Crewman with a Normal priority order, then the array must be in the order of High, Normal, Low * A Crewman can only accept MAXPENDING pending number of orders

Overrides:
giveOrder in class Job
Parameters:
newOrder - Order to be executed
Returns:
true or false, depending of success

completeOrder

public boolean completeOrder()
Will complete the current order by removing the current order and assigning the next pending order. as the current order. All other orders will then also move up. There should be no holes in your array You MUST use the OrderIterator to iterate through the list of pending orders

Returns:
true or false, depending on success

printPendingOrders

public java.lang.String printPendingOrders()
Returns a string of all the pending orders for the caller to print You MUST use an ObjectIterator to iterate through the pending orders

Returns:
the string of pending orders

executeSession

public void executeSession(Person user)
Prints the Crewman menu and then retrieves the user's input. It then executes the actions of the Crewman based on the user's input. The menu should look like this:
 		Crewman menu:
		1. Print Current Order
  	2. Print Pending Orders
  	3. Complete Order
  	4. Log Off
 		What would you like to do?
 
If a user wants to complete an order, then print the success/failure of that command.

Overrides:
executeSession in class Job
Parameters:
user - An instance of the caller

toString

public java.lang.String toString()
Returns a string describing the Crewman class. Make sure that it includes the Crewman's current order and his Superior Officer

Overrides:
toString in class Job
Returns:
String describing class