taxisrus.publicinterface
Interface ModelInterface

All Known Implementing Classes:
Model, FakeModel

public interface ModelInterface

ModelInterface Public interface to be used with Model object. PLEASE EMAIL INTERFACE CHANGE REQUESTS TO MIKAM TRIBE: margaux, ianli, kkchen, alexcho, meilye

Author:
mikam tribe

Method Summary
 Date addCustomer(Customer customer)
          Adds a customer in system.
PRECONDITION: Customer must have the following information set already:
- call-in time
- pickup address
- pickup time
- destination address
POSTCONDITION: customer's information is set
scheduler now has customer within domain
datastore knows of ride request
 boolean cabIsScheduled(Cab cab)
          Mark cab as scheduled.
 void cabRefusedRide(int cab_id, int zone_id)
          Called when the cab refuses a ride
we must update the cab in the model to be placed in the back
PRECONDITION:
POSTCONDITION:
 void cancelCab(int cab_id, Customer cancelledCustomer)
          Cancels scheduled cab, assumes customer field in cab is set
scheduler calls when cancelled customer not found in waiting customer queue
and msg needs to be relayed to cab console, cab will be placed back into front of zone which cab is found in
assume customer's cab field will be set elsewhere (by scheduler)
PRECONDITION: customer corresponding to cab has been canceled
POSTCONDITION: cab is still in busy cab list, everything but zone is set correctly
 Boolean cancelCustomer(String customerPhone, String customerLastName, String customerFirstName)
          Cancel the customer, returns true for successful cancellation
 Date changeCustomer(Customer oldCust, Customer newCust)
          Changes customer in the system For Dispatcher UI
 Vector getAllBusyCabs()
          Returns the list of busy cabs.
PRECONDITION: none
POSTCONDITION: none
 Vector getArrivingCabs(int zone_id)
          Returns all arriving cabs to specified zone;
to be used when no cabs available in desired zone.
Assumes that the customer field in the cab is set correctly
 Cab getBusyCab(int cab_id)
          Gets (but does NOT remove) the cab with cab_id from the busy list.
-used during actual customer pick-up
PRECONDITION: none
POSTCONDITION: none
 Vector getBusyCabsInZone(int zone_id)
          Returns list of busy cabs in specified zone (destination zone of busy cab)
PRECONDITION: none
POSTCONDITION: none
 Cab getCab(int cab_id)
          Returns referenced Cab object from zone list--does not remove cab
PRECONDITION: cab is waiting in a zone
POSTCONDITION: none
 Customer getCustomer(String customerPhone, String customerLastName, String customerFirstName)
          Returns the Customer identified by the phone number and last name
PRECONDITION: scheduler contains the target customer
POSTCONDITION: none
 ManagerReport getManagerReport(int typeOfReport, int specificity, int timeInterval, Date from, Date to)
          Passes ManagerReport request from ManagerUI to DataStore
 Vector getOpenCabs(int zone_id)
          Returns all open cabs within specified zone.
PRECONDITION: none
POSTCONDITION: none
 Zone getZone(int zone_id)
          Returns specified zone.
PRECONDITION: zone_id is a legal zone
POSTCONDITION: none
 boolean isCreditCardAccepted(double chargedAmount, String creditCardNumber)
          "Approve" credit card
-- passes the charge amount and creditCardNumber to bank and sees if the card is approved
PRECONDITION: none
POSTCONDITION: none
 boolean manualDispatchCab(Cab cab, Customer customer)
          Dispatches specified cab to specified customer (NOT YET IMPLEMENTED).
 Boolean registerCabToModel(CabConsoleInterface cabConsole, int cab_id, int driver_id, String gps)
          registers the cab in the model if cab_id and driver_id are valid (in database)
PRECONDITION: both cab and driver identified by cab_id and driver_id registers for the first time.
POSTCONDITION: a cab object corresponding to the cab console has been created and placed in its respective zone in the model
 void rescheduleCustomer(Customer failedScheduling)
          Passes a customer object to a DispatcherUI object for rescheduling.
 boolean rideRequest(Customer iWannaRide, int cab_id)
          For Scheduler
Relays ride request from scheduler to cab console
Responsible only for relaying messages
PRECONDITION: valid cab id
cab currently in the model
POSTCONDITION: none
 boolean updateModelCabInfo(String cust_info)
          For Cab Console:
Called after console updates referenced cab object, this method triggers necessary
model updates
Case 0: customer dropped off
Case 2: customer has been picked up
Case 3: customer has canceled and cab has been canceled
PRECONDITION: cab console has changed its status and needs to be updated in the model
case 0: cab is busy
case 2: none
case 3: cab has been emptied of its customer and is in the busy cab list
POSTCONDITION: case 0: cab is waiting in its appropriate zone
case 2: pickup time for customer in database has been updated
case 3: cab waiting at front of zone's cab list
 

Method Detail

addCustomer

public Date addCustomer(Customer customer)
Adds a customer in system.
PRECONDITION: Customer must have the following information set already:
- call-in time
- pickup address
- pickup time
- destination address
POSTCONDITION: customer's information is set
scheduler now has customer within domain
datastore knows of ride request
Parameters:
customer - customer object to be added
Returns:
ETA (Date object) the estimated pickup time

cancelCustomer

public Boolean cancelCustomer(String customerPhone,
                              String customerLastName,
                              String customerFirstName)
Cancel the customer, returns true for successful cancellation
Parameters:
customer_id -  
customerLastName -  
Returns:
Boolean object (NOT PRIMITIVE!)

changeCustomer

public Date changeCustomer(Customer oldCust,
                           Customer newCust)
Changes customer in the system For Dispatcher UI
Parameters:
old - customer - copy
new - customer
Returns:
ETA (Date object) of changed customer, if null, customer was not found anymore or customer did not/could not be changed --- Design Decisions --- A change customer request essentially falls in two catagories: changes that require a customer reschedule, and changes that require only a update of customer fields in various places in system. A change customer request can find the custmer in two states inside the scheduler: before or after cab assignment. If one of 3 fields in customer changed: pickup addr, pickup time, #riders then reschedule customer, otherwise just update in appropriate places In case of reschedule, call to cancel customer will percolate to scheduler, db, and cab console if necessary.

getCustomer

public Customer getCustomer(String customerPhone,
                            String customerLastName,
                            String customerFirstName)
Returns the Customer identified by the phone number and last name
PRECONDITION: scheduler contains the target customer
POSTCONDITION: none
Parameters:
customerPhone -  
customerLastName -  
Returns:
customer that matches the phone and name

getCab

public Cab getCab(int cab_id)
Returns referenced Cab object from zone list--does not remove cab
PRECONDITION: cab is waiting in a zone
POSTCONDITION: none
Returns:
if cab is in the model and currently available, return the cab, else return null

getBusyCab

public Cab getBusyCab(int cab_id)
Gets (but does NOT remove) the cab with cab_id from the busy list.
-used during actual customer pick-up
PRECONDITION: none
POSTCONDITION: none
Returns:
the cab with cab_id taken from the busy list. If the cab with cab_id is not in the busy list, returns null.

getBusyCabsInZone

public Vector getBusyCabsInZone(int zone_id)
Returns list of busy cabs in specified zone (destination zone of busy cab)
PRECONDITION: none
POSTCONDITION: none
Returns:
Vector list of cabs in the zone

getAllBusyCabs

public Vector getAllBusyCabs()
Returns the list of busy cabs.
PRECONDITION: none
POSTCONDITION: none
Returns:
Vector list of busy cabs

getZone

public Zone getZone(int zone_id)
Returns specified zone.
PRECONDITION: zone_id is a legal zone
POSTCONDITION: none
Parameters:
zone_id - ID of requested zone
Returns:
the requested zone object

manualDispatchCab

public boolean manualDispatchCab(Cab cab,
                                 Customer customer)
Dispatches specified cab to specified customer (NOT YET IMPLEMENTED).
Parameters:
cab - the cab to be dispatched
customer - the customer that will be picked up
Returns:
True if the cab is dispatched to customer; false, otherwise.

getOpenCabs

public Vector getOpenCabs(int zone_id)
Returns all open cabs within specified zone.
PRECONDITION: none
POSTCONDITION: none
Parameters:
zone_id - zone to get cabs from
Returns:
Vector list containing all available cabs within zone

getArrivingCabs

public Vector getArrivingCabs(int zone_id)
Returns all arriving cabs to specified zone;
to be used when no cabs available in desired zone.
Assumes that the customer field in the cab is set correctly
Parameters:
zone_id - the ID of the zone from which to get arriving cabs
Returns:
all arriving cabs to specified zone

rideRequest

public boolean rideRequest(Customer iWannaRide,
                           int cab_id)
For Scheduler
Relays ride request from scheduler to cab console
Responsible only for relaying messages
PRECONDITION: valid cab id
cab currently in the model
POSTCONDITION: none
Parameters:
Customer - who requests ride
cab_id - of cab to request
Returns:
true if cab console confirms request

cabIsScheduled

public boolean cabIsScheduled(Cab cab)
Mark cab as scheduled. It is assumed that a customer has been matched with a cab, that is, its member variable for a customer is set.
PRECONDITION: cab has been assigned a customer
POSTCONDITION: scheduler has knowledge of cab/customer assignment
Parameters:
cab - is the busy cab (reservation)
Returns:
true if successful update in model

cancelCab

public void cancelCab(int cab_id,
                      Customer cancelledCustomer)
Cancels scheduled cab, assumes customer field in cab is set
scheduler calls when cancelled customer not found in waiting customer queue
and msg needs to be relayed to cab console, cab will be placed back into front of zone which cab is found in
assume customer's cab field will be set elsewhere (by scheduler)
PRECONDITION: customer corresponding to cab has been canceled
POSTCONDITION: cab is still in busy cab list, everything but zone is set correctly
Parameters:
cab_id - of cab to cancel

cabRefusedRide

public void cabRefusedRide(int cab_id,
                           int zone_id)
Called when the cab refuses a ride
we must update the cab in the model to be placed in the back
PRECONDITION:
POSTCONDITION:
Parameters:
cab_id - ID of cab that refused
zone_id - ID of zone where cab is located

updateModelCabInfo

public boolean updateModelCabInfo(String cust_info)
For Cab Console:
Called after console updates referenced cab object, this method triggers necessary
model updates
Case 0: customer dropped off
Case 2: customer has been picked up
Case 3: customer has canceled and cab has been canceled
PRECONDITION: cab console has changed its status and needs to be updated in the model
case 0: cab is busy
case 2: none
case 3: cab has been emptied of its customer and is in the busy cab list
POSTCONDITION: case 0: cab is waiting in its appropriate zone
case 2: pickup time for customer in database has been updated
case 3: cab waiting at front of zone's cab list
Parameters:
must - be in this format:
"cab_id \n status \n gps \n meter \n mileage \n pickuptime", or
"cab_id \n status \n date"
where status = 0 dropped off customer, 1 accepted fare, 2 picked up customer
where date = Date.toString()
assumes: cab_id is int,
gps is "(,)",
meter is double, status is true or false,
ride mileage is float

registerCabToModel

public Boolean registerCabToModel(CabConsoleInterface cabConsole,
                                  int cab_id,
                                  int driver_id,
                                  String gps)
registers the cab in the model if cab_id and driver_id are valid (in database)
PRECONDITION: both cab and driver identified by cab_id and driver_id registers for the first time.
POSTCONDITION: a cab object corresponding to the cab console has been created and placed in its respective zone in the model
Returns:
true if both id's are valid, false otherwise

isCreditCardAccepted

public boolean isCreditCardAccepted(double chargedAmount,
                                    String creditCardNumber)
"Approve" credit card
-- passes the charge amount and creditCardNumber to bank and sees if the card is approved
PRECONDITION: none
POSTCONDITION: none
Parameters:
chargedAmount - amount to charge
creditCardNumber - credit card number
Returns:
whether the card was accepted

getManagerReport

public ManagerReport getManagerReport(int typeOfReport,
                                      int specificity,
                                      int timeInterval,
                                      Date from,
                                      Date to)
Passes ManagerReport request from ManagerUI to DataStore
Parameters:
typeOfReport - - type of report
specificity -  
timeInterval -  
from - - starting date for query
to - - ending date for query
Returns:
the manager report

rescheduleCustomer

public void rescheduleCustomer(Customer failedScheduling)
Passes a customer object to a DispatcherUI object for rescheduling. Used if automatic scheduling fails and SchedulerInterface.ASK_CABS_ONLY_ONCE is set to true.
Parameters:
Customer - - Customer who needs to be manually scheduled.


API documentation for build 958