CSIT121 ⎯ Programming Fundamentals
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
SCIT
School of Computing and Information Technology
Spring 2021
CSIT121 ⎯ Programming Fundamentals
Assignment 1 (10 marks)
General 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.
● Logical structures and statements are properly used for specific purposes.
● Read the assignment specification carefully, and make sure that you follow whatever directed in this assignment. In every assignment that you will submit in this subject, you must put the following information in the header of your program:
/*------------------------------------------------------My name:My student number:My course code: CSIT121My email address:Assignment number: 1-------------------------------------------------------*/
Objectives
This assignment requires you to design and implement a Computer Parts Ordering System (CPOS) in Java that help a PC shop to take and manage orders from its customers.
Background
A PC shop needs a computer application to take and manage orders from its customers. In general, when a customer orders some computer parts from the shop, the customer shall firstly provide some personal information, such as the name, the gender, and the contact and delivery details. Then the customer can choose different compute parts based on the category, the brand, the model and the price. The application shall automatically record the customer’s choice and calculate the total price of the customer’s order. Eventually, a summary of the order shall be displayed on the screen for the customer’s final confirmation. Once the customer confirms the order, the order will be submitted and the customer can quit from the application.
At current stage, the PC shop only can provide some limited parts within the categories of CPU, Motherboard, Memory, Graphics Card, and Monitor. The details of each category are given below.
CPU:
Brand
|
Core
|
Model
|
Price
|
Inter
|
i5
|
9600K
|
$323
|
Inter
|
i7
|
9700K
|
$462
|
Inter
|
i7
|
9700F
|
$396
|
Inter
|
i9
|
9900K
|
$591
|
AMD
|
4
|
Ryzen 2200
|
$200
|
AMD
|
6
|
Ryzen 3600
|
$310
|
AMD
|
8
|
Ryzen 3700
|
$489
|
AMD
|
8
|
Ryzen 5800
|
$669
|
Motherboard:
Socket
|
Brand
|
Model
|
Price
|
Inter
|
Gigabyte
|
H81M-DS2
|
$129
|
Inter
|
Asus
|
J40051-C
|
$169
|
Inter
|
Msi
|
Mpg-2390
|
$225
|
Inter
|
Gigabyte
|
Z490
|
$471
|
AMD
|
Gigabyte
|
B-450
|
$117
|
AMD
|
Asus
|
A320I
|
$128
|
AMD
|
Msi
|
B450
|
$232
|
AMD
|
Gigabyte
|
X570S
|
$679
|
Memory:
Socket
|
Brand
|
Size
|
Model
|
Price
|
DDR3 |
Kingston
|
8G
|
KCP316ND8
|
$116
|
DDR3
|
ADATA
|
16G
|
AX4U360038G18
|
$189
|
DDR3
|
G.Skill
|
8G
|
F3-10666CL9D
|
$96
|
DDR4 |
Kingston
|
8G
|
KCP426SS8
|
$93
|
DDR4
|
G.Skill
|
16G
|
F4-2666C18S
|
$158
|
DDR4
|
Crucial
|
32G
|
CT32G4SFD832A
|
$259
|
Graphics Card:
Socket
|
Brand
|
Model
|
Price
|
NVIDA
|
Gigabyte
|
GeForce RTX 3070
|
$1999
|
NVIDA
|
Asus
|
GeForce RTX 3070
|
$1899
|
NVIDA
|
Msi
|
GeForce RTX 3080
|
$3099
|
AMD
|
Gigabyte
|
Radeon RX 6900
|
$3699
|
AMD
|
Asus
|
Radeon RX 6900
|
$3199
|
AMD
|
Msi
|
Radeon RX 6900
|
$2699
|
Monitor:
Brand
|
Size
|
Model
|
Price
|
Acer
|
24
|
K242HYLB
|
$194
|
LG
|
32
|
32QN600
|
$506
|
Asus
|
16
|
MB16ACZ
|
$429
|
Msi
|
27
|
MP271QP
|
$399
|
BenQ
|
32
|
PD3200Q
|
$653
|
Philips
|
27
|
272M8CZ
|
$289
|
Your program shall contain at least the following 8 classes to take and manage the orders from customers.
● CPU class: The CPU class is used to describe the basic information of a CPU unit. It shall contain field data such as the brand, the core number, the model and the price of a CPU. You shall also define constructors, mutators and accessors for the CPU class. The toString() method shall be overridden to return a CPU object as a string.
● Motherboard class: The Motherboard class is used to describe the basic information of a Motherboard unit. It shall contain field data such as the socket type, the brand, the model and the price of a motherboard. You shall also define constructors, mutators and accessors for the Motherboard class. The toString() method shall be overridden to return a Motherboard object as a string.
● Memory class: The Memory class is used to describe the basic information of a Memory unit. It shall contain field data such as the socket type, the brand, the size, the model and the price of a memory. You shall also define constructors, mutators and accessors for the Memory class. The toString() method shall be overridden to return a Memory object as a string.
● GraphicsCard class: The GraphicsCard class is used to describe the basic information of a GraphicsCard unit. It shall contain field data such as the socket type, the brand, the model and the price of a graphics card. You shall also define constructors, mutators and accessors for the GraphicsCard class. The toString() method shall be overridden to return a GraphicsCard object as a string.
● Monitor class: The Monitor class is used to describe the basic information of a Monitor unit. It shall contain field data such as the brand, the size, the model and the price of a monitor. You shall also define constructors, mutators and accessors for the Monitor class. The toString() method shall be overridden to return a Monitor object as a string.
Please note that for CUP, Motherboard, GraphicsCard, Memory, and Monitor classes, only the price can be modified. All other attributes are CONSTANTS.
● Customer class: The Customer class is used to describe the basic information of a customer. It shall contain field data such as the ID (a constant), the name, the gender, the mobile number, and the delivery address. The customer ID is a string starting with a capital letter ‘C’ and follow by five random digits. You shall also define constructors, mutators and accessors for the Customer class. The toString() method shall be overridden to return a Customer object as a string.
● Order class: The Order class is used to describe the basic information of a customer’s order. Its class field shall contain an order ID (a constant), the total price, a Customer object, and other computer part objects ordered by the customer. The order ID is a string starting with a capital letter ‘O’ and follow by five random digits. It is assumed each customer can only order one computer part in each category. You shall define constructors, mutators and accessors for the Order class and override the toString() method to return the Order object as a string.
● OrderingSystem class: The OrderingSystem class is the primary class and contains the main() method. In the class field data, it contains an order list (ArrayList<Order>) to keep all customer orders, a customer list (ArrayList<Customer>) to keep all customers, a cpu list (ArrayList<CPU>), a motherboard list (ArrayList<Motherboard>), a memory list (ArrayList<Memory>), a graphics card list (ArrayList<GraphicsCard>) and a monitor list (ArrayList<Monitor>) to indicate all available computer parts. The following steps shall be done in the main() method.
a. Use the computer part information provided in the above tables to create computer part objects and add the objects to the correct computer part list.
b. Display the welcome message to the customer and ask the customer to provide the customer ID. If it is a new customer, the customer will be requested to provide more personal information to complete the registration, i.e., a new customer object will be created and added to the customer list.
c. Display a main menu with eight items to the customer, which are (1) add a cpu, (2) add a motherboard, (3) add a memory, (4) add a graphics card, (5) add a monitor, (6) view/modify the order, (7) submit the order and exist, and (8) exist without the purchase.
d. When Item (1) ~ (5) is selected, all available computer parts in the selected category will be firstly displayed in a list with details. The customer can add one part to the order or go back to the main menu without adding any computer part.
e. When Item (6) is selected, the summary of the customer’s order will be displayed firstly. The summary shall contain the customer personal information (via toString() method of the Customer class), the ordered computer parts (via toString() method of each computer part class), and the total price of the order. The customer can remove any computer part from the order and/or go back to the main menu without the modification.
f. When Item (7) is selected, if the total price of the order is not zero, the order will be added to the order list and the customer will exist the system (i.e., the program is terminated).
g. When Item (8) is selected, the order will not be added to the order list and the customer exists the system directly without the purchase.
The whole UML activity diagram of the system and an example of application outputs is given below. The customer’s inputs are highlighted by blue colour.
Tasks
Task 1 (2 marks): Complete the program design by using the UML class diagram. The class diagram shall
● contains at least the eight classes mentioned above;
● contains class name, fields and methods definitions for each class;
● use correct and sufficient UML notations;
● clearly specify the associations between classes;
● clearly specify the multiplicities for both sides of the associations.
Task 2 (6 marks): Implement the system according to the UML class diagrams. The program shall
● be consistent with the UML class diagrams;
● follow the conventions for naming all classes, variables, and methods;
● provide sufficient comments;
● use proper blank spaces, indentation and braces to make your code easy to read and understand;
● follow the specified steps in the UML activity diagram;
● be able to repeat the main menu until the customer exists the system.
Task 3 (2 marks): Compilation and test.
● Please carefully compile your program and make sure your program can pass the compilation by using “javac” command.
● Test your program to 1) add a new customer, 2) add a cpu, a motherboard, a memory, a graphics card and a monitor, 3) display the order summary, 4) replace an existing computer part with a different one in the same category, and 5) submit the order.
● The total price must be updated when the customer adds, removes or replaces a computer part.
● 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 1). Email submission is NOT accepted.
● Please submit an individual PDF document (OrderingSystem.pdf) to contain your answers for Task 1 and Task 3. For Task 1, please include your UML class diagram. For Task 3, please include the snapshots to clearly shows the compilation and the execution of your program based on the testing request.
● Please submit all java codes for Task 2 and make sure the primary class’s name is OrderingSystem.java.
2021-08-12