Reference no: EM133168056
CSIT121 Programming Fundamentals - University of Wollongong
Requirements:
• You should create your programs with good programming style and form using proper blank spaces, indentation and braces 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 for readers to understand what your code intends to achieve.
• Please add the following header in your program:
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.
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 Pierrot,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 your 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.
b. The order number start from 1 when there is no order in the container orders. The new order number is the size of the container orders plus 1.
c. The order date is the current 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 Order>> 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.
b. If the customer selects an ordered product, then clicks the button Unorder<<, 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
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: 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: 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 current order list via the GUI;
• Be able to export the customer's orders to a single text file.
Task 3: 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).
Attachment:- Programming Fundamentals.rar