You are on page 1of 2

FINAL PRACTICAL EXERCISE (Self-directed task)

ASSESSED TASK: 16 marks

Consider the following UML design for a Product class:

Product
-name: String
-stockLevel: int
-price: double

+Product(String, int, double)


+reStock(int): int
+sell(int): double
+setPrice(double)
+getName() : String
+getStockLevel() : int
+getPrice(): double
The attributes of this class allow details of a given product (name, stock level and
price) to be stored. The methods of this class should behave as follows:

+Product(String, int, double) The constructor initialises receives three


parameters and uses them to initialise the name of
the product, the number of items initially stocked
and the price per item respectively.

+reStock(int): int Receives the number of new items of to stock,


updates and returns the new stock level.

+sell(int) : double Receives the number of items sold, reduces the


stock level accordingly (first checking to see if
enough items are in stock) and returns the cost of
the order. You should consider how to
communicate a sell request that cannot be met.
Extra credit will be given for using exceptions to do
this.

+setPrice(double) Receives and sets a new price for the product.

+getName() : String These methods return the values of the respective


+getStockLevel() : int attributes.
+getPrice(): double
The Task

a) Implement the Product class.

(4 marks)

b) Develop a Graphical User Interface for this Product class, to allow products
to be re-stocked, sold and re-priced. Your student number should be visible in
the title bar of this GUI.

You will get marks for the functionality of the application as well as the quality
of the interface. The better the functionality provided (such as error checking)
and the more features in your GUI (such as menu bars and pop up boxes) the
higher the marks.

(8 marks)

Note: If you cannot develop a GUI you can develop a text based interface but,
while you can still get some marks for functionality, you will receive much
fewer marks for your interface. Your student ID should still be displayed on
your screen.

Extra Challenge

Allow for a many products to be stored in a list (using an array for example).

(4 marks)

FOR THE STUDENT NUMBER ON THE TITLE BAR OF GUI, USE NUMBER 222333
THIS IS AN INDIVIDUAL TASK

You will be asked to upload all the files making up your application to Moodle by
Friday 5th May 2017 (no later than 11.55pm).

You might also like