Online Store Application - CEMS UWE

... an online shopping application enables the User to search for items online,
browse a list of products available, select item and add to product shopping
basket, view the contents .... The import statements used in this exercise are
import java.util.scanner; which enables text to be enter via the keyboard, and
import java.text.

Part of the document


Online Store Application
Modelling and Simulation

David A. Shotton
University of the West of England


Abstract

This paper demonstrates the second phase in the design of an online
shopping application. In extending the development of phase (1), additional
functionality is provided to enable the user to order items on line and
review the status of items purchased through use of a shopping basket. The
requirement is for a standalone application to be executed using Netbeans
IDE.

Introduction and Approach

An introduction to the modelling and simulation of a standalone online
shopping cart is provided in (Sec.1.0). The Scope and requirements of the
system are defined with Use Case scenarios (Sec.2.0) and the architectural
design is modelled using Class Diagrams (Sec.3.0).

The structure and dynamic behaviour of the system is discussed through use
of a Sequence Diagram (Sec.4.0). Source code for the Shopping Cart is
explained and the 'User Instructions' for the complied version of the code
to simulate the Shopping Basket is explained (Sec.5.0).

For testing the code, a discussion of the verification and validation
approach is provided (Sec.6.0). A Discussion relating to the design of the
online system concludes (Sec.7.0).

1.1 Modelling and Simulation Approach

The initial assignment introduced the object oriented approach and IDE
environment for modelling the features an online shopping system. An
important aspect of the initial modelling approach is that it provides a
solution which can be extended for phase (2/3).

The second phase will extend the design and modelling of an online-store
and simulate the basic functionality required to enter order details and
progress the status of a shopping basket online. The functionality required
to register and maintain the basket is not included.

2.0 Scope and Requirements

2.1 Purpose of the System

The basic functionality presented in the model of an online shopping
application enables the User to search for items online, browse a list of
products available, select item and add to product shopping basket, view
the contents of the basket and check out an order online.

2.2 Requirements and Deliverables

The requirements of phase (1) were to design an architecture which would
allow the Customer to browse and order items via an online shopping basket.
It is a requirement of phase (2) to simulate the functionality of a simple
shopping basket and extend the design.


User requirements and high level designs are delivered through the
following artefacts;

. Use Cases and textural descriptions (phase 1)
. Use Case Diagram (phase 3)
. Sequence Diagram and Control Flow
. Class Diagram for Online Shopping System
. Executable source code (phase 1)
. Run time instructions for model simulation

2.3 Use Case Scenarios

In the phase (1) model, the use case enabled the customer to raise an
online order for a range of items including Books, CD's and Laptops. The
Use Cases were extended to include scenarios for processing and order and
shipping to customer and consisted of three distinct areas of development
involving Shopping, Ordering and Customer Shipment / Details.

The Use Case main Flow (Fig 1.1) involves the following scenarios;

. The system asks the user to register and login to initiate ordering
. The user browses the online line shopping system using a catalogue
. The system requests that item is selected and is subsequently added to
the cart
. The system enables the user view the contents of the shopping cart
. The user confirms selection and checks out the contents of the basket


[pic]
Fig 1.1 Use Cases - Phase (1)





2.4 Phase 2.0 Requirements

The use cases and the class attributes are summarised in table 1.1 and
table 1.2 respectively (See Appendix 1.0). A detailed class structure
diagram (Appendix 2.1) identifies the key attributes for browsing and
ordering items online which from the basis of phase (2).

3.0 Architectural Design

The initial class structure diagram has been extended and includes 13
classes which define the design for he online shopping system. The high
level architecture and collaborative data flows are visually represented
below (Fig 1.2). The segments relating to Online Ordering, involving the
Shopping Cart and Item Ordering classes, from the basis of a detailed
analysis in phase (2)

[pic]

Fig 1.2 Collaboration Diagram

The functionality required to satisfy phase (2) and (3) extends to include
segments for the customer online registration and shopping basket. An
executable version of the code to demonstrate the functionality of the
shopping basket at run-time is provided (Appendix 3.0).

3.1 Relationship between Classes

The class diagram presented for phase (1) (Appendix 2) summarises the
relationships between the classes and their associations. These are defined
as either direct or indirect binary associations and Aggregation defines
the level of integration between classes and subclasses.

A Composite Aggregation is used to define a dependent relationship between
component and aggregate. Class associations were discussed in element (1)
in relation to inheritance.

4.0 Methods and Associated Operations

The application includes an Array and a Loop function which allows the user
to shop online repeatedly for multiple purchases. At run time the program
processes each item selected by proceeding through the loop function which
reads in the name, price and quantity. The items selected are in turn added
to the shopping basket. The items and the total price are quantified.



4.1 Package Structure

The package structure design used in Java programming identifies closely
related classes representing a single function. Grouping these classes
together will help to reduce aggregation and/or composition which improves
class coupling.

Breaking the phase (1) model down into packages for 'Customers', 'Book
Shop' and 'Online Ordering' (Fig 1.2 above) helped to define and group
closely related classes representing a single function thereby limiting
aggregation and/or composition and improving coupling.

4.2 Java Import Declarations

The java import statement is used to reference classes used in other
packages and those chosen from the standard java class libraries. This may
be a single member of the nested package, or if not known, the contents of
the total package represented by a wild card (*;).

The Java installation includes predefined class packages the most commonly
used are: applets java.applet, language extensions java.lang, utilities
java.util, formatters java.text, file streams java.io, GUIs java.awt and
javax.swing,

The java.lang is frequently called and therefore loaded automatically. The
import statements used in this exercise are import java.util.scanner; which
enables text to be enter via the keyboard, and import
java.text.NumberFormat; which converts a floating point value (X) to a
string of given size (w) with a specified number (n) of decimals.

4.3 Sequence Diagram and Control Flow

The Sequence diagram used here was generated from the NetBeans IDE having
first created a Dependency diagram for the Shopping Cart and Item Classes
(Appendix 2.2).

The Shopping Cart class is used to model the dynamic behaviour and control
flow of the online systems through use of a Sequence Diagram (Appendix 2.3)
The Shopping Cart is responsible for adding and removing items that a
customer plans to buy.

A more elaborate model would illustrate when An item is added, AddItem( )
as an operation that adds merchandise to the cart and a Remove Item( ) is
an operation that removes an item and indicate how a message is created and
destroyed as part of the control flow.

5.0 User Instructions - Distribution and Executable

5.1 Format of Source Code

The simple online shopping application involves the use of standard input
and output, double data type, if statements and simple arithmetic
comparison on double, if statements, String Concatenation and String
comparisons (Appendix 3.0).

In order to make the application suitable to generate output to screen
using the Netbean IDE, it was necessary to incorporate multiple instances
of the scanner class on 'system.in', used for input and 'system.out' in
association with println() to output text messages to the screen.



5.2 Non-executables associated with the Shopping Cart.Java Package

The Java files associated with the Online Shopping application are stored
in the package for online-store and include files for the Shopping Class,
Item Class and the Shopping Cart Class.

The 'Item.java' and the 'ShopingCart.java' files are compiled and deugged
however they are not designed to be in an executable format for output
through the IDE, these were included for the production the Dependency
diagram and Sequence Diagram.

5.3 Manifest File Distribution

The application has been packaged as an executable Jar File which means
that any libraries specified in the application, in addition to the JDK,
are copied into dist/lib. The manifest file is updated to include entries
that designate main class and any libraries that are on the project's class
path.

The manifest for the OnlineStore file is show as;

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 10.0-b23 (Sun Microsystems Inc.)
Main-Class: onlinestore.Main
Class-Path:
X-COMMENT: Main-Class will be added automatically by build

5.4 Instructions for Running Java Programme

Select the 'ShoppingCart.java' file from the 'OnlineStore Package' and re-
compile the file using the drop-down menu. Ensure the file is selected and
Run from the drop down menu.

Note that using F9 and F6 may incur problems. The application will now
display in the IDE's output window and the following message will appear;
"please enter item name".

5.5 System Response to User Commands

Directions for using the simplified Online Sh