PDC
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Register Class Reference

#include <Register.h>

Inheritance diagram for Register:

Public Member Functions

void advanceTime (int t)
 
void push (const int val)
 

Protected Attributes

int remaining
 

Static Protected Attributes

static int transactTime = 10
 

Detailed Description

Represents a register line in a store checkout area. Each integer in the base queue represents a cart to be processed. Time is measured in units for scanning a single item in a cart.

Member Function Documentation

void Register::advanceTime ( int  t)
inline

Advance this register's simulation by a specified amount of time

Parameters
tnon-negative number of units of time to advance the register
State change
Prints message for each completed cart, and for empty queue
Pseudocode
while t>0 and a cart remains in the queue:
  if remaining > t:
    subtract t units from remaining, and set t=0
    print message about progress on that cart
  else:
    subtract remaining units from t
    print message about completion of that cart
    remove that cart from the queue
    if a next cart exists in the queue:
      remaining = transactTime + (number of items in that next cart)
if no carts remain:
  print message about no carts remaining
void Register::push ( const int  val)
inline

Override queue::push to maintain remaining in the case of an empty queue

Parameters
valRepresents a new cart

Member Data Documentation

int Register::remaining
protected

Remaining time to complete front cart in queue; no specified value for an empty queue

int Register::transactTime = 10
staticprotected

time per cart to perform a transaction


The documentation for this class was generated from the following file: