Objectives This assignment requires you to design and implement a Graphic User Interface (GUI) for the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. Customer -code: String -name: String -address: String -phone: String +Customer() +getCode(): String Order 0..n -orderNumber: int -code: String -orderDate: String -orderDetails: ArrayList -total: double +Order() +calculateTotal (): void +readData(Scanner); void +writeData(Formatter): void +toString(): String interface>> MyFilelo 0..n 0..n +main(String[]); void +OrderSystem() +loadCustomers(): void +loadProducts(): void +saveOrders(): void Jo..n JTextArea JList 1..n Order System -customers: ArrayList -products: ArrayList -orders: ArrayList Do..n JButton Product -pname: String -supplier: String -category: String -stockQuantity: int -price: double +Product() +getName(): String OrderDetail -pname: String -price: double -orderQuantity: int -subTotal: double +Order Detail() +Order Detail(String, double, int): +calculateSubTotal(): void JFrame ActionListener interface>> ListSelectionListener 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,030-0074321 ANATR, Ana Trujillo, Avda. de la Constitucin 2222,(5) 555-4729 ANTON, Antonio Moreno, Mataderos 2312,(5) 555-3932 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 (,). 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 WOLLONGONG 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 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 Assignment 3_sample Processing.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 current 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 for 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 errors, incorrect result, program is not up to spec, poor comments, poor indentation, meaningless identifiers, required numeric constants are not defined, the program Start the OrderSystem program, the GUI displayed like below. Order System Customer Code ALFKI ANATR ANTON AROUT BERGS BLAUS BLONP BOLID BONAP BOTTM New Order Assignment 3 sample processing Messages Customer details Save Order X If the user clicks the button New Order without select a customer code, the error message is displayed. Order System Customer Code ALFKI ANATR ANTON AROUT BERGS BLAUS BLONP BOLID BONAP BOTTM New Order Messages Select a customer Customer details I Save Order X A customer code is selected, display the customer details in the right area. Order System Customer Code ALFKI ANATR ANTON AROUT BERGS BLAUS BLONP BOLID BONAP BOTTM New Order Messages Customer details Customer code: AROUT Name: Thomas Hardy Address: 120 Hanover Sq. Phone: (171) 555-7788 Save Order X Click the button New Order, a new window for the ordering is displayed. When a product has zero stock quantity selected, click the button Order>> does not add the product to the order list. A message "The product is not in stock" is displayed in the message area. Order products Product Name Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Product name: Alice Mutton Supplier. Pavlova Ltd. Category: Meat/Poultry Stock quantity: 0 Price: 39.0 OK Order>> Unorder < < Cancel Messages The product is not in stock. Order I X When a product is in stock (stock quantity > 1), click the button Order>> can add the product name to the order list. The order details of the product are displayed. If the product has been ordered before, the program updates the order quantity and reduces the stock quantity for the product. Order products Product Name Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Product name: Aniseed Syrup Supplier: Exotic Liquids Category: Condiments Stock quantity: 12 Price: 10.0 4 OK Order>>> Unorder < < Messages The product is ordered. Cancel Order Aniseed Syrup Product name: Aniseed Syrup Price: 10.0 Order quantity: 1 Sub total: 10.0 Order products Product Name Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Product name: Boston Crab Meat Supplier. New England Seafood Cannery Category: Seafood Stock quantity: 120 Price: 18.4 BD Ok Order>>> Unorder < < Messages The product is ordered. Cancel Order Aniseed Syrup Boston Crab Meat Product name: Boston Crab Meat Price: 18.4 Order quantity:3 Sub total: 55.199999999999996 I X Order products Product Name Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Chocolade Cite de Blaye Escargots de Bourgogne Filo Mix Flotemysost Geitost Product name: Filo Mix Supplier: G'day Mate Category: Grains/Cereals Stock quantity: 37 Price: 7.0 Ok Order>> Unorder < < Messages The product is ordered. Cancel Order Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chocolade Cite de Blaye Product name: Filo Mix Price: 7.0 Order quantity: 1 Sub total: 7.0 I X 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. Customer -code: String -name: String -address: String -phone: String +Customer() +getCode(): String Order 0..n -orderNumber: int -code: String -orderDate: String -orderDetails: ArrayList -total: double +Order() +calculateTotal (): void +readData(Scanner); void +writeData(Formatter): void +toString(): String interface>> MyFilelo 0..n 0..n +main(String[]); void +OrderSystem() +loadCustomers(): void +loadProducts(): void +saveOrders(): void Jo..n JTextArea JList 1..n Order System -customers: ArrayList -products: ArrayList -orders: ArrayList Do..n JButton Product -pname: String -supplier: String -category: String -stockQuantity: int -price: double +Product() +getName(): String OrderDetail -pname: String -price: double -orderQuantity: int -subTotal: double +Order Detail() +Order Detail(String, double, int): +calculateSubTotal(): void JFrame ActionListener interface>> ListSelectionListener 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,030-0074321 ANATR, Ana Trujillo, Avda. de la Constitucin 2222,(5) 555-4729 ANTON, Antonio Moreno, Mataderos 2312,(5) 555-3932 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 (,). 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 WOLLONGONG 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 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 Assignment 3_sample Processing.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 current 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 for 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 errors, incorrect result, program is not up to spec, poor comments, poor indentation, meaningless identifiers, required numeric constants are not defined, the program Start the OrderSystem program, the GUI displayed like below. Order System Customer Code ALFKI ANATR ANTON AROUT BERGS BLAUS BLONP BOLID BONAP BOTTM New Order Assignment 3 sample processing Messages Customer details Save Order X If the user clicks the button New Order without select a customer code, the error message is displayed. Order System Customer Code ALFKI ANATR ANTON AROUT BERGS BLAUS BLONP BOLID BONAP BOTTM New Order Messages Select a customer Customer details I Save Order X A customer code is selected, display the customer details in the right area. Order System Customer Code ALFKI ANATR ANTON AROUT BERGS BLAUS BLONP BOLID BONAP BOTTM New Order Messages Customer details Customer code: AROUT Name: Thomas Hardy Address: 120 Hanover Sq. Phone: (171) 555-7788 Save Order X Click the button New Order, a new window for the ordering is displayed. When a product has zero stock quantity selected, click the button Order>> does not add the product to the order list. A message "The product is not in stock" is displayed in the message area. Order products Product Name Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Product name: Alice Mutton Supplier. Pavlova Ltd. Category: Meat/Poultry Stock quantity: 0 Price: 39.0 OK Order>> Unorder < < Cancel Messages The product is not in stock. Order I X When a product is in stock (stock quantity > 1), click the button Order>> can add the product name to the order list. The order details of the product are displayed. If the product has been ordered before, the program updates the order quantity and reduces the stock quantity for the product. Order products Product Name Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Product name: Aniseed Syrup Supplier: Exotic Liquids Category: Condiments Stock quantity: 12 Price: 10.0 4 OK Order>>> Unorder < < Messages The product is ordered. Cancel Order Aniseed Syrup Product name: Aniseed Syrup Price: 10.0 Order quantity: 1 Sub total: 10.0 Order products Product Name Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Product name: Boston Crab Meat Supplier. New England Seafood Cannery Category: Seafood Stock quantity: 120 Price: 18.4 BD Ok Order>>> Unorder < < Messages The product is ordered. Cancel Order Aniseed Syrup Boston Crab Meat Product name: Boston Crab Meat Price: 18.4 Order quantity:3 Sub total: 55.199999999999996 I X Order products Product Name Chang Chartreuse verte Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix Chocolade Cite de Blaye Escargots de Bourgogne Filo Mix Flotemysost Geitost Product name: Filo Mix Supplier: G'day Mate Category: Grains/Cereals Stock quantity: 37 Price: 7.0 Ok Order>> Unorder < < Messages The product is ordered. Cancel Order Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers Chai Chang Chartreuse verte Chef Anton's Cajun Seasoning Chocolade Cite de Blaye Product name: Filo Mix Price: 7.0 Order quantity: 1 Sub total: 7.0 I X
Expert Answer:
Answer rating: 100% (QA)
Here is a more indepth solution with code snippets to guide you in creating the program as specified in your requirements Class Diagram The first step is to create a class diagram that represents the ... View the full answer
Related Book For
Project Management The Managerial Process
ISBN: 9781260570434
8th Edition
Authors: Eric W Larson, Clifford F. Gray
Posted Date:
Students also viewed these programming questions
-
for the equality test for M and N. The question concerns how to represent multisets of strings within ML. For each of the given data representations (a), (b) and (c) describe how you would implement...
-
Inverse permutation. Write a program that reads in a permutation of the integers 0 to n-1 from n command-line arguments and prints the inverse permutation. (If the permutation is in an array a[], its...
-
State three commonly used research methods in behavioral science.
-
Determine each of the following as being either true or false. If it is false, explain why. The equation x 2 = (y 1) 2 represents a hyperbola.
-
Founded in 1966 as a trader of oil and oil products, Vitol is a company with no external shareholders. All shareholders are also employees. It is a conglomerate company of energy companies that work...
-
Special Revenue Fund, Voluntary Nonexchange Transactions. The City of Eldon applied for a competitive grant from the state government for park improvements such as upgrading hiking trails and bike...
-
6. MAC =9 The use of energy is one of the major causes of pollution and greenhouse gases that lead to climate change. It is desirable to reduce the emissions from energy use. Suppose there are two...
-
Consider the function below, that takes a string and a character (called letter) as input: int TaskH (char* word, char letter) { int i = 0; int p = -1; while (word [i] if } '\0') { (word[i] ==...
-
Company has 50 000 stocks. Each stock has a market price of 3 dollars and an expected return of 10%. Company has a debt with a market value of 150 000 dollars. The risk-free rate is 4%. Then: Stock...
-
An onboarding training program includes the basic information that employees need to understand their new job. Increasingly, onboarding training programs use collaborative meeting and learning...
-
A stock has a correlation with the market of 0.4. If the Sharpe ratio of the market portfolio is 0.7, what is the Sharpe ratio of the stock? (Hint: algebraically manipulate the SML equation.)
-
Of the common network communication protocols, which one is a common protocol used in place of Internet Protocol (IP) when persistent connections are not necessary or desirable? Group of answer...
-
We have three semiannual corporate bonds just issued (the settlement date is 10/16/2023). The bonds pay interests every six months. Bond A : 15-year, 5.5% coupon rate, $1,000 face value Bond B :...
-
Question a. What degrees of freedom are associated with the test of between group differences? b. Provide the critical F value for this scenario. c. Based on the presented results, what conclusions...
-
If you want to solve a minimization problem by applying the geometric method to the dual problem, how many variables and problem constraints must be in the original problem?
-
Place in order the following countries in terms of what you think would be the least to most corrupt: United States, Denmark, Saudi Arabia, Canada, Australia, France, China, Thailand, Botswana, Chile...
-
What is the difference between avoiding a risk and retaining a risk?
-
1 . Why is it important to identify the critical path before starting a project? 2 . On what kind of projects would the critical path be irrelevant?
-
Example In January 2004, a Mars Exploration Rover touched down on the surface of Mars and rolled out for exploration ( Figure
-
A battery-operated wall clock no longer keeps timeneither hand moves. Develop a hypothesis explaining why it fails to work, and then make a prediction that permits you to test your hypothesis....
-
Does the snowflake have rotational symmetry in Figure 1.6? If yes, describe the ways in which the flake can be rotated without changing its appearance. Does it have reflection symmetry? If yes,...
Study smarter with the SolutionInn App