Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CPT106 C++ Programming and Software Engineering II

Individual Project

Fundamental of class and object

Project Number

3

Contribution to Overall Marks

30%

Release date

10 April 2023

Submission Deadline

25 May 2023, 23:59

How should the work be submitted?

SOFT COPY ONLY !

(MUST be submitted through Learning Mall so that we can run your programs during marking.)

Assessment Overview

This assessment aims at testing some basic concepts of C++ programming and coding in the software development environment (Visual Studio).  To distribute the workload of the individual project more evenly throughout the whole semester,  we divided it into 3 smaller individual projects for you to complete separately. This is the third individual project.

What should be submitted?

Only your  C++ source code file (,cpp) should be submitted to Learning Mall (LM). Your grade will also be given through LM. There are several steps for you to note:

1.   You should create a solution named “CPT106Solution” .

2.    Create a project named “Project 3” .

3.    Create a CPP file for each class.

4.    Create the main function in a CPP file of “123456.cpp” (123456 is your student ID)

5.    Include clear comments in your code to make it easy to understand.

6.    Only submit the cpp files to the LMO.

7.    ALL programs MUST compile and run in one of Visual Studio environments in VS2013/2016/2019/2022.

Project 3 (100)

Online trading systems can help customers buy goods from the Internet. In this question, you are required to write a program to simulate the trading procedure and allow customers to query and buy some goods.

Tasks:

(1)  Create a Product class with several private member variables, such as product id, product name, product amount and price. (5 marks)

(2)  Create a base class Person with several private member variables, such as person name, gender, mobile number and address. The gender should be an enum. (5 marks)

(3)  Create a subclass Customer based on the Person class. It has extra private member variables, such as customer id, capital and a vector of products the customer is purchasing. Each             customer has 5,000 RMB initial capital. (5 marks)

(4)  Create a subclass Manager based on Person class. The manager has extra private member variables, such as age and title. (5 marks)

(5)  Create a MainProcess class. It has private member variables, such as a vector of products to   save all product information, a vector of customers to save all customers, a manager who can manage customers and products and a customer who is purchasing products. In addition, it    also has some functions to output operation menus both for managers and customers to        choose from. (5 marks)

(6)  When the program runs, it shows a menu as follows: (5 marks)

 

Fig.1. Main operation menu

There are two roles in this online trading system (manager and customer). Different roles have different functions.

(7)  If the input is 1, then move to manager’s menu as follows: (5 marks)

 

Fig.2. Manager’s operation menu

The manager can add new products, query products, add new customers and query customers. If the user inputs 5, then the program will move to the parent menu shown in Figure 1 (main     operation menu).

a)   Add products:  manager can add new products into a product vector so that customers can buy these products. (5 marks) 

 

Fig.3. Operation of adding products

The manager can continue to input product id, name, amount and price to create and     add new products into the product vector. Duplicated product id cannot be added to the product vector. When the manager inputs 0 to stop adding, the manager operation          menu will output on the window, and the manager can input another number to do         other operations.

b)   Query products: manager can input a product id to query a particular product or input “*” to list all products in the product vector. Output No product found!” if there is no particular product. (5 marks)

 

Fig.4. Operation of querying products

c)    Add customers: manager can add new customers to the customer vector. (5 marks) 

 

Fig.5. Operation of adding customers

The manager can input customer id, name, gender, mobile number and address to          create and add new customers into the customer vector. Duplicated customer id cannot be added to the customer vector. When the manager inputs 0 to stop adding, the            manager operation menu will be outputted on the window, and the manager can input  another number to do other operations.

d)   Query customers: manager can input a customer id to query a particular customer or   input “*” to output all customers in the customer vector. “No customer found!” will be outputted if there is no particular customer. (5 marks)

 

Fig.6. Operation of querying customers

e)    Move to parent menu: if the manager inputs 5, then the program moves to the main operation menu shown in Figure 1. (5 marks)

(8)  On the main operation menu, if the user inputs 2, then the system will ask the user to input a customer id to confirm which customer will purchase products. If the customer id exists in the customer vector, then the operation menu for customers will be outputted as Figure 7 shows. (5 marks)

 

Fig.7. Customers operation menu 

otherwise, ask users to input a new customer id or a special string “quit” to move to the parent operation menu shown in Figure 8 (it means that you should create at least one customer          before you can enter into the customer operation menu and start to purchase products).

 

Fig.8. Failed to find the customer Id

a)   Add products into cart:  a customer can add products into the cart so that the customer can buy these products. Customer can input product id and the amount he/she wants to buy. The program will show a reminder if the customer does not have enough capital or the amount the customer wants is larger than the available amount of the product. The program should output successful information if the adding operation runs successfully. In addition, the amount of product in the product vector should be deducted                     accordingly. (5 marks)

 

Fig.8. Operation of adding products into cart

b)   Query products in cart: customers can query all products added in the cart. The       customer can input a specific product id to query one product or input “*” to list all products in the cart. (5 marks)

 

Fig.9. Operation of querying products in cart

c)    Check up: customer can check up the bill for all products in the cart. It will list               customer’s id, name, gender and capital, all products in the cart and the total price. (5 marks)


 

Fig.10. checking up operation

If the cart is checked up successfully, the capital of the customer should be deducted based on the total price of products the customer has bought.

(9)  Make sure your source code has some comments (5 marks) to help us understand and can be compiled successfully (15 marks).


Marking Scheme



Class definition                              80% (5% for each member in classes)

Comments                                      5%

Correctness & Robustness               15%