Microsoft Word - Assignment3
- 1/5 -
SCIT
School of Computing and Information Technology
Spring 2022
CSIT121 Programming Fundamentals
Assignment 3 (10 marks)
Due Time and Date:
Due by Saturday 22nd Oct XXXXXXXXXX:30 pm
General Requirements:
• You should create your programs with good programming style and form using proper blank
spaces, indentation and
aces to make your code easy to read and understand.
• You should create identifiers with sensible names.
• You should make comments to describe your code segments where they are necessary fo
eaders to understand what your code intends to achieve.
• Please add the following header in your program:
*------------------------------------------------------
My name:
My student number:
My course code: CSIT121
My email address:
Assignment number: 3
-------------------------------------------------------*
Objectives
This assignment requires you to design and implement a Graphic User Interface (GUI) for the
customers and products Order System (OS) by using Java Swing. Meanwhile, the file I/O and
exception handling shall be implemented in the assignment.
Background
You are required to design, implement, and test an ordering system with the Graphic User Interface
(GUI). The program shall
1) Load customers’ data and products’ data when the program starts.
2) Display GUI to help a customer to make new orders.
3) Handle possible exceptions during the interaction between the customer and the system.
4) Save the customer orders to a text file.
The UML class diagram of OS is given below. You can add new classes, methods and/or attributes
in the UML class diagram but CAN NOT delete any existing classes, attributes, and methods. Your
java implementation must be consistent with the UML class diagram.
- 2/5 -
A customers and products OS application initially loads data of customers and products from the
text files.
The format of a file customers.txt contains the data like
ALFKI,Maria Anders,Obere Str. 57, XXXXXXXXXX
ANATR,Ana Trujillo,Avda. de la Constituci¢n 2222, XXXXXXXXXX
ANTON,Antonio Moreno,Mataderos 2312, XXXXXXXXXX
Each row is a record of a customer. The fields of each customer consist of customer code, name,
address, and phone number. Each field is separated by a character comma (,).
- 3/5 -
The format of a file products.txt contains the data like
Alice Mutton,Pavlova Ltd.,Meat/Poultry,0,39.00
Aniseed Syrup,Exotic Liquids,Condiments,13,10.00
Boston Crab Meat,New England Seafood Cannery,Seafood,123,18.40
Camembert Pie
ot,Gai paturage,Dairy Products,19,34.00
Each row is a record of a product. The fields of a product consist of product name, supplier name,
category, stock quantity, and unit price. Each field is separated by a character comma (,).
In this assignment, we can assume that the input text files are customers.txt and
products.txt.
The detailed requests are as follows:
1. Update your UML diagram
You shall update the UML class diagram by adding a new GUI class (for a new order). You can add
classes, methods, and attributes. Please make sure your implementation is consistent with you
UML class diagram.
2. Design and implement a GUI.
The OrderSystem class shall contain Swing components, such as JFrame, JPanel, JLabel,
JTextField, JButton, JList, JTextArea, etc. With the GUI, a customer can complete the order of
products.
3. Customer ordering
After initialization, the GUI of customers and products OS will be displayed. If a customer is
selected from a list, the details of the customer are displayed. The customer can start a new window
when clicks a button New Order and place a new order of products.
a. The new order number and order date are automatically generated.
. The order number start from 1 when there is no order in the container orders. The new orde
number is the size of the container orders plus 1.
c. The order date is the cu
ent system date.
4. Order products
The customer can start to order any products via the GUI. When the customer selects a new product
from a list, the product’s details are displayed.
a. The customer can click the button Orde
to place the product in the order list. The stock
quantity of the product should be decreased by 1. Display the updated product details and
order details.
. If the customer selects an ordered product, then clicks the button Unorde
, the product
order quantity is decreased by 1. If the order quantity is 0, then the product is removed from
the order list. Display the updated product details and order details.
c. If the customer clicks the button Ok, the new order is stored in the container orders and quits
the window.
d. If the customer clicks the button Cancel, quit the window without saving the new order.
5. Save the order details
When a customer clicks the button Save Order, all the order details are saved to a text file
orders.txt.
6. Exception handling
- 4/5 -
The system shall be able to handle the exceptions during the interaction between the customer and
the system. The exceptions may include invalid information when loading customers and products.
Invalid data when a product is ordered.
Check the sample processing in a file Assignment3_sampleProcessing.pdf and watch
the demonstration video for more details.
Tasks
Task 1 (1 mark): Update the UML class diagram based on the design given above. You are allowed
to add new classes, more attributes, or more methods.
Task 2 (7 marks): Implement the program according to the updated UML class diagram by using
Java. The program shall
• Be consistent with the UML class diagram;
• Design and implement the GUI by using Java Swing. Please make sure to use JFrame,
JPanel, JLabel, JTextField, JButton, JList, JTextArea, etc. in your GUI;
• Follow the conventions for naming all classes, variables, and methods, and provide
sufficient comments;
• Be implemented by using the advanced OOP features such as inheritance, polymorphism,
abstraction, interface, and/or class downcasting.
• Be able to initialise the customers and products OS;
• Be able to help the customer to complete the ordering via the GUI;
• Be able to handle possible exceptions during the ordering process;
• Be able to view or modify the cu
ent order list via the GUI;
• Be able to export the customer’s orders to a single text file.
Task 3 (2 marks): Compilation and test.
Please compile your program with ‘javac’ and carefully test your program for all the requests.
Test your program to all cases in GUI.
Please do not define the package in your program (a special alert for students who use IDE to
complete the assignment).
Submission:
• Please submit your solution to Moodle (Assignment 3). Email submission is NOT accepted.
• Please submit an individual PDF document (OrderSystem.pdf) that contains your answers fo
Task 1 and Task 3. Please include the updated UML class diagram for Task 1. Include the
snapshots to clearly shows the compilation, and the execution of your program for Task 2. You
need to demonstrate all tasks with the GUI.
• Please submit all java codes for Task 2 and make sure the primary class’s name is
OrderSystem.java. Please submit the text file orders.txt created by your program in the
test.
NOTES:
Enquiries about the marks can only be made within a maximum of 1 week after the assignment results are
published. After 1 week the marks cannot be changed.
Mark deductions: compilation e
ors, inco
ect result, program is not up to spec, poor comments,
poor indentation, meaningless identifiers, required numeric constants are not defined, the program
- 5/5 -
uses approaches which have not been covered in the lectures. The deductions here are merely a
guide. Marks may also be deducted for other mistakes and poor practices.
ALFKI,Maria Anders,Obere Str. 57, XXXXXXXXXX
ANATR,Ana Trujillo,Avda. de la Constituci¢n 2222, XXXXXXXXXX
ANTON,Antonio Moreno,Mataderos 2312, XXXXXXXXXX
AROUT,Thomas Hardy,120 Hanover Sq., XXXXXXXXXX
BERGS,Christina Berglund,Berguvsv„gen 8, XXXXXXXXXX
BLAUS,Hanna Moos,Forsterstr. 57, XXXXXXXXXX
BLONP,Frederique Citeaux,24 Place Kleber, XXXXXXXXXX
BOLID,Martin Sommer,C/ Araquil 67, XXXXXXXXXX
BONAP,Laurence Lebihan,12 rue des Bouchers, XXXXXXXXXX
BOTTM,Elizabeth Lincoln,23 Tsawassen Blvd., XXXXXXXXXX
BSBEV,Victoria Ashworth,Fauntleroy Circus, XXXXXXXXXX
CACTU,Patricio Simpson,Ce
ito 333, XXXXXXXXXX
CENTC,Francisco Chang,Sie
as de Granada 9993, XXXXXXXXXX
CHOPS,Yang Wang,Hauptstr. 29, XXXXXXXXXX
COMMI,Pedro Afonso,Av. dos Lusiadas 23, XXXXXXXXXX
CONSH,Elizabeth Brown,Berkeley Gardens 12 Brewery , XXXXXXXXXX
DRACD,Sven Ottlieb,Walserweg 21, XXXXXXXXXX
DUMON,Janine La
une,67 rue des Cinquante Otages, XXXXXXXXXX
EASTC,Ann Devon,35 King George, XXXXXXXXXX
ERNSH,Roland Mendel,Kirchgasse 6, XXXXXXXXXX
FAMIA,Aria Cruz,Rua Oros 92, XXXXXXXXXX
FISSA,Diego Roel,C/ Moralzarzal 86, XXXXXXXXXX
FOLIG,Martine Rance,184 chausse de Tournai, XXXXXXXXXX
FOLKO,Maria Larsson,�kergatan 24, XXXXXXXXXX
FRANK,Peter Franken,Berliner Platz 43, XXXXXXXXXX
FRANR,Carine Schmitt,54 rue Royale, XXXXXXXXXX
FRANS,Paolo Accorti,Via Monte Bianco 34, XXXXXXXXXX
FURIB,Lino Rodriguez,Jardim das rosas n. 32, XXXXXXXXXX
GALED,Eduardo Saavedra,Rambla de Catalu¤a 23, XXXXXXXXXX
GODOS,Jose Pedro Freyre,C/ Romero 33, XXXXXXXXXX
GOURL,Andr‚ Fonseca,Av. Brasil 442, XXXXXXXXXX
GREAL,Howard Snyder,2732 Baker Blvd., XXXXXXXXXX
GROSR,Manuel Pereira,5 Ave. Los Palos Grandes, XXXXXXXXXX
HANAR,Mario Pontes,Rua do Paco 67, XXXXXXXXXX
HILAA,Carlos Hernandez,Ca
era 22 con Ave. Carlos Soublette #8-35, XXXXXXXXXX
HUNGC,Yoshi Latimer,City Center Plaza 516 Main St., XXXXXXXXXX
HUNGO,Patricia McKenna,8 Johnstown Road, XXXXXXXXXX
ISLAT,Helen Bennett,Garden House Crowther Way, XXXXXXXXXX
KOENE,Philip Cramer,Maubelstr. 90, XXXXXXXXXX
LACOR,Daniel Tonini,67 avenue de l'Europe, XXXXXXXXXX
LAMAI,Annette Roulet,1 rue Alsace-Lo
aine, XXXXXXXXXX
LAUGB,Yoshi Tannamuri,1900 Oak St., XXXXXXXXXX
LAZYK,John Steel,12 Orchestra Te
ace, XXXXXXXXXX
LEHMS,Renate Messner,Magazinweg 7, XXXXXXXXXX
LETSS,Jaime Yo
es,87 Polk St. Suite 5, XXXXXXXXXX
LILAS,Carlos Gonzalez,Ca
era 52 con Ave. Bolvar #65-98 Llano Largo, XXXXXXXXXX
LINOD,Felipe Izquierdo,Ave. 5 de Mayo Porlamar, XXXXXXXXXX
LONEP,Fran Wilson,89 Chiaroscuro Rd., XXXXXXXXXX
MAGAA,Giovanni Rovelli,Via Ludovico il Moro 22, XXXXXXXXXX
MAISD,Catherine Dewey,Rue Joseph-Bens 532, XXXXXXXXXX
MEREP,Jean Fresniere,43 rue St. Laurent, XXXXXXXXXX
MORGK,Alexander Feuer,Heerstr. 22, XXXXXXXXXX
NORTS,Simon Crowther,South House 300 Queens
idge, XXXXXXXXXX
OCEAN