API for Supermarket Controller: Analysis Document

Document Number: E02

Date of Issue: 8 February 2005

Author: John B. Wordsworth
J.B.Wordsworth@ex.ac.uk

Copyright: © J. B. Wordsworth 2004, 2005

Preface

This document record an object-oriented analysis of supermarket controller operations.

Table of contents

  1. Introductory requirements statement
  2. Use cases
  3. Abstract data model
  4. Use cases in detail

See the document history for a record of changes.

Introductory requirements statement

A store controller in a supermarket is to be programmed to support the store's operations. The store has a number of checkouts for registering customers' purchases, and a database of lines sold, prices, and stock levels. The following diagram illustrates the physical configuration.

Physical configuration of supermarket

The store administrator can add checkouts to the configuration as they open for business each day, and can remove them as they close. A checkout cannot be removed if it is processing a customer's purchases. The warehouse manager can add or remove lines, set prices, and change stock levels or descriptions, though lines can only be removed when all the checkouts are closed. Each line has a unique line number corresponding to the barcode on the product. Each checkout can process the purchases of one customer at a time. The checkout operator starts each customer's bill by pressing a key on the checkout keyboard, and then scans each item in a customer's basket. As each item is scanned, its description and price are displayed on the checkout screen. When all the items have been scanned the checkout operator presses another key to get the bill printed. The bill shows the description and price of each item purchased and the total. The price charged for an item is the price recorded in the database for that line at the time that the bill is prepared. The checkout is then ready to process the next customer.

The following statechart explains the operation of the checkout.

Statechart for the operation of a checkout

Back to the table of contents.

Use cases

The actors are the store administrator, the warehouse manager, and the checkouts.

The use cases are as follows. (They should be developed from the task analysis, and from the operational characteristics of the checkout.)

Use case diagram

The following table provides more informal information about the use cases. In this table the columns are as follows:

Use caseIntentionInputs
AddCheckout Allows the administrator to add a checkout to the configuration. checkout_number
RemoveCheckout Allows the administrator to close a checkout when it has no more customers. checkout_number
StartBill Allows the checkout operator to start a bill for a new customer. checkout_number
AddLineToBill Allows the checkout operator to add a scanned item to the bill. checkout_number
line_number
RemoveLineFromBill Allows the checkout operator to remove an item from the bill. checkout_number
line_number
EndBill Allows the checkout operator to get a printout of the customer's bill after all the items have been scanned. checkout_number
AddLine Allows the warehouse manager to add a line to those sold in the store. line_number
line_description
line_price
line_stock
RemoveLine Allows the warehouse manager to remove a line from those sold in the store. line_number
SetLinePrice Allows the warehouse manager to change the price of a line. line_number
new_price
ChangeLineStock Allows the warehouse manager to increase or decrease the amount of stock of a line. line_number
stock_change

Back to the table of contents.

Abstract data model

The following UML class diagram captures the structure of the data, and attempts to make some parts of the user vocabulary more precise. It acts as an abstract data model for the system to be developed.

Class diagram

Constraints

(A1) The Store is an aggregation of Checkout and Line objects. The aggregation relationships are called checkouts, and lines.

(A2) Each Checkout object has a number.

(A3) Each Checkout object is in the checkouts relationship.

(A4) No two Checkout objects have the same number.

(A5) Each Line object has a number, a description, a price, and a stock level.

(A6) Each Line object is in the lines relationship.

(A7) No two Line objects have the same number.

(A8) Each checkout has at most one Bill object associated with it, each Bill object is associated with exactly one Checkout object, and this relationship is called the is_preparing relationship.

(A9) Each bill object is associated with zero or more Line objects, each Line object can be associated with zero or more Bill objects, and this relationship is called the is_on relationship. In this relationship a given Line object can be associated with a given Bill object more than once.

Initialisation

The initial state of the Store has no Checkout objects, and no Line objects, and this state satisfies the constraints.

Back to the table of contents.

Use cases in detail

The use cases are now reviewed with the class diagram in mind. A more precise statement is given of the function of each use case.

The function of each use case is described in a table with the following columns:

AddCheckout

InputsSituationChange of stateOutputs
checkout_number checkout_number is the same as the number of a Checkout object. None Message: Checkout number already in use.
checkout_number is not the same as the number of any Checkout object. A new Checkout object is created with no associated Bill object. The number of the new Checkout object is checkout_number. The new Checkout object is added to the checkouts relationship. Message: Checkout added.

The following diagram illustrates the state change when a checkout is added.

Object diagrams for AddCheckout

Back to the list of use cases, or to the table of contents.

RemoveCheckout

InputsSituationChange of stateOutputs
checkout_number There is a Checkout object whose number is checkout_number, and the checkout object has no associated Bill object. The Checkout object is removed from the checkouts relationship. Message: Checkout removed.
There is a Checkout object whose number is checkout_number, but the Checkout object is in the is_preparing relationship with a Bill object. None. Message: Checkout busy.
There is no Checkout object whose number is checkout_number. None. Message: Checkout not found.

The following diagram illustrates the state when a checkout cannot be removed.

Object diagram of failing removeCheckout

Back to the list of use cases, or to the table of contents.

StartBill

InputsSituationChange of stateOutputs
checkout_number There is a Checkout object whose number is checkout_number, and this Checkout object has no associated Bill object. A new Bill object with no associated Line objects is created and associated with the Checkout object. Message: Bill started.

The following diagram illustrates the state change when a bill is started at a checkout.

Object diagrams of StartBill

Back to the list of use cases, or to the table of contents.

AddLineToBill

InputsSituationChange of stateOutputs
checkout_number
line_number
There is a Checkout object whose number is checkout_number. The Checkout object is in the is_preparing relationship with a Bill object. There is a Line object whose number is line_number. A new link in the is_on relationship is formed between the Bill object and the Line object. The description and price of the Line object are displayed on the checkout screen.
There is a Checkout object whose number is checkout_number. The Checkout object is in the is_preparing relationship with a Bill object. There is no Line object whose number is line_number. None Message: Line not found.

The following diagram illustrates the state change when a line is added to a bill.

Object diagrams of addLineToBill

Back to the list of use cases, or to the table of contents.

RemoveLineFromBill

InputsSituationChange of stateOutputs
checkout_number
line_number
checkout_number is the number of a Checkout object that is associated with a Bill object in the is_preparing relationship. There is a link in the is_on relationship between the Bill object and a Line object whose number is line_number. The detected link is removed. Message: Line removed.
checkout_number is the number of a Checkout object that is associated with a Bill object in the is_preparing relationship. There is no link in the is_on relationship between the Bill object and a Line object whose number is line_number. None. Message: Line not found.

The following diagram illustrates the state change when a line is removed from a bill.

Object diagrams of RemoveLineFromBill

Back to the list of use cases, or to the table of contents.

EndBill

InputsSituationChange of stateOutputs
checkout_number checkout_number is the number of a Checkout object that is associated with a Bill object. The Bill object is associated with one or more Line objects. The Bill object and its links to the Checkout object and to Line objects are removed. List of descriptions and prices of the Line objects associated with the Bill object. Sum of all the prices.
checkout_number is the number of a Checkout object that is associated with a Bill object. The Bill object is not associated with any Line objects. None. Message: Nothing to list.

The following diagram illustrates the state change when a bill for which there are lines is ended.

Object diagrams of EndBill

Back to the list of use cases, or to the table of contents.

AddLine

InputsSituationChange of stateOutputs
line_number
line_description
line_price
line_stock
line_number is not the number of any Line object. A new Line object is created whose number is line_number, description is line_description, stock is line_stock, and price is line_price. The new Line object is added to the lines relationship, but is not associated with any other objects. Message: Line added.
line_number is the number of a Line object. None. Message: Line number already in use.

The following diagram illustrates the state change when a line is added.

Object diagrams for AddLine

Back to the list of use cases, or to the table of contents.

RemoveLine

InputsSituationChange of stateOutputs
line_number line_number is not the number of a Line object. None. Message: Line not found.
line_number is the number of a line object. There are Checkout objects in the checkouts relationship. None. Message: Checkouts present.
line_number is the number of a line object. There are no Checkout objects in the checkouts relationship. The Line object is removed from the lines relationship. Message: Line removed.

The following diagram illustrates the state when a line cannot be removed.

Object diagram of failing RemoveLine

Back to the list of use cases, or to the table of contents.

SetLinePrice

InputsSituationChange of stateOutputs
line_number
new_price
line_number is not the number of any Line object. None. Message: Line not found.
line_number is the number of a Line object. The price attribute is changed to new_price. Message: Price changed.

The following diagram illustrates the state change when the price of a line is changed.

Object diagrams for SetLinePrice

Back to the list of use cases, or to the table of contents.

ChangeLineStock

InputsSituationChange of stateOutputs
line_number
stock_change
line_number is not the number of a Line object. None. Message: Line not found.
line_number is the number of a Line object. The stock in the Line object is adjusted by stock_change. Message: Stock level changed.

The following diagram illustrates the state change when the stock of a line is changed.

Object diagrams for ChangeLineStock

Back to the list of use cases, or to the table of contents.


Document history

5 October 2004

First issued.

8 February 2005

Reissued with the following amendments:

Back to the table of contents.