Assignment 4
Assignment 4
Assignment 4
Deadline: 4-Dec-2022 (Sun) 23:59
Objectives
This assignment allows you to practice using classes, objects, lists, strings, and file I/O.
Task
In this assignment, your task is to use Visual Basic to develop a GUI-based application to maintain some
staff records. Each staff record consists of the following elements:
After creating a Windows Form Application in Visual Studio, it initially contains a file named Form1.vb,
please rename it to be StaffRecordSystem.vb. After that, please create a new class file named
StaffRecord.vb, which contains the definition of the StaffRecord class as follows:
' Each object created from this class represents a staff record
Public Class StaffRecord
' four private instance variables
Private id_ As String
Private name_ As String
Private position_ As String
Private salary_ As Integer
After that, in StaffRecordSystem.vb, you can use the StaffRecord class to create StaffRecord objects,
where each object represents a staff record. In addition, you are required to use a List to store all the
StaffRecord objects. In the beginning of the program, there is no staff record in the system.
1
Your program has to provide the following features:
1. Add a staff record by specifying the ID, the name, the position, and the salary.
After the record is added, display a successful message.
But for the following cases, display an appropriate error message and no record will be
added:
i. The ID, the name, or the position is an empty string.
ii. The ID, the name, or the position contains commas.
iii. The salary cannot be converted to an integer.
iv. The salary is a non-positive number.
v. A staff record with the same ID already exists.
7. Increase the salary of a staff by specifying the ID and the increase rate (in %), which is a number
with or without decimal places. The new salary will be rounded the nearest integer (rounding up
or to the nearest even). For example, if the original salary is $25,580 and the increase rate is 3.1%,
the new salary will be $26,373.
After the salary in the record is updated, display a successful message with the new salary.
But for the following cases, display an appropriate error message and the record will not
be updated:
i. The staff record cannot be found.
ii. The increase rate cannot be converted to a Decimal (e.g., contains characters).
iii. The increase rate is not a positive number.
2
8. Compute the total sum of the salaries of all the staff records in the system.
If there is no staff record, the result will be $0.
M001,Alice Ho,Manager,35000
S102,Bob Chan,Sales,18500
S250,Chloe Chu,Sales,21000
If the file can be saved successfully, display a message to indicate the number of records
saved.
If the file cannot be saved, display an appropriate error message.
Your program should not crash when there is any IO exception.
Note that in StaffRecordSystem.vb, if you want to define a constructor (this is optional, depending on the
class design), you will need to call InitializeComponent() as follows:
End Sub
3
Saving the Project Files
Please use “Save All” to save all the project files in one location but avoid using “Save <file_name>.vb As”
to save some of the files in other locations. Otherwise, we may not be able to open your submission
successfully.
Assessment Scheme
Correctness 80%
Class Design 10%
Readability (E.g., comments (required), meaningful identifiers, clear user interface) 10%
Testing Platform
Microsoft Visual Studio Community 2022, Windows 10
Declaration
As required by the University, please place the following declaration as the comment in the beginning of
your VB source code.
Submission
Please follow the following steps to submit your work.
Step 1: Zip your Visual Basic project folder into a zip file Assg4_<your_student_id>.zip, where
<your_student_id> should be replaced by your student ID (e.g. Assg4_1234567890.zip).
C:\Users\<user_name>\source\repos
Step 2: Go to BlackBoard and login your account by using your CWEM password.
4
Step 4: Upload your zip file prepared in Step 1.
Resubmissions are allowed. But only the latest one will be counted. 10% of your marks will be deducted
for late submission each day after the deadline. Late submissions more than three days will not be graded.