THE HONG KONG POLYTECHNIC UNIVERSITY
Computer Programming (ENG2002) 2013/14 Assignment 3
A. Instructions
1.
2.
3.
4.
You should submit ONE compressed file of your whole solution folder with the name: [Link] file (where xxxxxxxx
is your student ID number) on or before 29 Mar 2014 via email: ykmok@[Link]. Marks will be deducted for each
day delayed and also for incorrect filename.
You must add a comment to show your name and student ID at the beginning of the header files.
Your programs need to be well commented. Lacking comments will result in down-grading.
You are NOT advised to share a copy of your program source to your fellows. Plagiarism by others may make your mark
zero.
B. The Programming Task
By using Visual Studio 2010 C++, you need to implement a Windows Forms application program that enables users to manage
orders of personal computer (PC) which is similar to the previous assignment 2 but working in graphical mode. First of all, you
MUST create a folder and a project with the name as your student id.
There are two data files [Link] & [Link] provided in which data will be loaded into your program.
1. the data sequence in the file [Link] (customer information):
Seq.
Property
Limitation
1
order_no
unique integer starting from 1001(the first order), each new order will increment this number by one
2
name
customer name with not more than 30 characters and allow space character input
3
phone
phone number of integer value between 10000000 and 99999999 inclusively
4
total_cost
stores total cost for this order
5
diff_pc
contains number of different pc configuration
2. the data sequence in the file [Link] (pc configuration information):
Seq.
Property
Purpose
1
order_no
this number should match and link to one of the order_no in the file [Link]
2
quantity
is the number of PCs of this configuration
3
brand
holds the brand name of PC
4
memory
contains the size of memory
5
harddisk
contains the size of harddisk
6
one_set_cost
the cost of a PC of one configuration
The program must be implemented with one class at least and with ifstream and ofstream to read and write the data files. You
may assume there are no more than thirty orders. Four brands of PC are available and their basic configurations are all equipped
with 4G memory and 1T harddisk:
Basic PC: 1. Acer ($5000) 2. Dell ($5500) 3. HP ($6000) 4. Lenovo ($4000)
User can pay more to upgrade memory and harddisk:
Memory: 1. 8G (+$300) 2. 16G (+$700) 3. 32G (+$1500)
Harddisk: 1. 2T (+$200) 2. 3T (+$600)
3. 4T (+$1200)
It is allowed to order PCs of different configuration and more than one set of PC of the same configuration.
Starting the program, it shows a Welcome window as Fig. 2 (a timestamp is shown at the bottom). The only way to close the
program is to click the Exit menu item.
Fig. 2
Fig. 2a
Page 1 of 4
version 1.1 18 Mar
Before working on the system, user should load the data files first; for example, clicking the option List all orders in Fig.2a
before loading data files, it shows a message window.
Before loading the data files, user is allowed to view and amend the original data files.
Fig. 3
Fig. 3a
Fig. 3b
Selecting menu strip item Admin View raw data files in Fig. 3 gives a new window as Fig. 3a and the data shown in Fig.
3a cannot be amended. After clicking Edit button, the window changes as Fig. 3b in which Edit button is disabled, data can
be edited and Save and Cancel buttons appear. Save button will save the data in the window to both files while the Cancel
button will discard the changes of data.
If Load data files is selected in Fig. 3, error message will be given if any one of the files cannot be opened and read. If it loads
data successfully, a message window as Fig. 4 will be shown and the no. of orders will be updated as well.
Fig. 4
When the option Make new order in Fig. 2 is clicked, a new window will be shown as Fig. 5 in which the Order no. will be
incremented automatically by one with the reference to the last record of order data.
Fig. 5
Fig. 5a
Page 2 of 4
version 1.1 18 Mar
If the input of phone no. is out of the range, it gives a message window as Fig.5a.
If any one of four brands is chosen, Memory and Harddisk options will be displayed and options of 4G and 1T will be default
selected, and no. of sets will be default to 1. unit cost and Total cost will be calculated.
Fig. 5b
Fig. 5c
unit cost should always be updated whenever there is a change of selection of brand, memory or harddisk. Total cost will be
updated when the value of no. of sets is changed. Total cost should also be accumulated all the cost of different PC configurations.
Fig. 5d
Fig. 5e
If the button of Order another PC configuration in Fig. 5d is clicked, the window will be refreshed as Fig. 5e where the value of
PC configuration no. will be incremented by one, memory and harddisk options will be hidden, no. of sets and unit cost will be
reset to zero.
Fig. 5f
Fig. 5g
Page 3 of 4
version 1.1 18 Mar
In Fig. 5f, the Confirm button will saved the input information to both files and display the saved order information. However,
the Cancel button will discard the input information with a message window shown as Fig. 5g. OK buttons of both Fig. 5f and
Fig. 5g will finally close the window of Order Information and go back the Welcome window as Fig. 2 and update the value of
Current no. of orders if one order is added successfully.
When the Search button is clicked in Fig. 2, the range of phone number should be checked firstly. Showing a message if the
record is not found; otherwise, display the order information with the given format as Fig. 6b
Fig. 6
Fig. 6a
Fig. 6b
Clicking the List all orders option in Fig. 2 will display a new window as Fig. 7 and the format of orders information must be
followed. The data shown cannot be edited. OK button will close the window and back to the Welcome window as Fig. 2
Fig. 7
Page 4 of 4
version 1.1 18 Mar