Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Faculty: ICT

Dept Computer Systems


PGG311T_PGM216D

Formative assessment 2 Examiner: J Ramabu

12 May 2022 - 3 hrs Moderator: J Jordaan

Full Marks: 75

Your
_______________________ LAB: PC:
Student number Lecturer:
Signature

Surname Initials

/75 %

Background

You have been appointed as an IT programmer to develop a system that can store and manage all
employees, where the program must also be able to compute statistics and various requests. For
further understanding, there is a demo provided.

Questions 1: Create a class named Employee [10 marks]

Have the following private data members: staffnumber, names, gender, age, salary.
Have a default constructor and initialize data members with your own values.
Have a method called setvalues which must set all data with values sent to them.
Have an accessor method (getter) for each data member.

Question 2: Load from file into array of objects button click [10 marks]

Create an employee object array as a global object or under public access specifier. When this
button is clicked, load data from the file(data.txt) using TStreamReader or TStringlist or Listbox and
load it into the array of objects through a setter method. Thereafter disable this button and enable
Load from array of objects onto listbox .

Open Rubric
Figure 1

Question 3: Load from array of objects into listbox button click [16 marks]

When this button is clciked, load the data from an array of objects into the listbox(data in the listbox
is separated by tab). The format of data in the listbox is in the form of line number, staff no, names,
gender, age, salary. Take note that line number in the listbox must be generated and the gender
abbreviation must be in full name.

Status bar should be published with total employees, total salaries, total males/females, date and
time (see format of the output at Figure 2 or demo).

Disabled Load from array of objects into listbox button, make sort by Age button and pnlsearch
button clickable.

Figure 2

2
Question 4: Sort by Age button click [14 marks]

When Sort by age button is clicked, the data in the list box must be sorted by age (in descending
order). After sorting, make sure that line numbers (first column) is restored to the original order.
Take a look at figure 3 or demo.

Figure 3

Question 5: Search button click [11 marks]

When search button is clicked, a search happens based on the staff number entered (spaces may be
left by the user on the left or right of the staff number in edit box must not be an obstacle for
search). If the staff number is found indicate the line number found in the listbox on the lblresults
(the font color also changes to blue), if not found also show a message on the same lblresults(the
font color also changes to red). Make sure that the user enters something in the textbox, if not show
error message See sample output on the screenshots below or demo.

Figure 4

3
Figure 5

Figure 6

Question 6: Onclick of a list box(lstCompanyEmployees) [14 marks]

Note: In this question you are only allowed to retrieve data from array of objects as you cannot
substring from lstCompanyEmployees to retrieve data. However, you are allowed to use itemIndex
property of lstCompanyEmployees in order to retrieve relevant data from array of objects.

When lstCompanyEmployees is clicked, a form called frminfo is called and updated with necessary
data, based on the current line clicked in the listbox. The data must be updated in that form
(frminfo) in the string grid(stginfo) and listbox(lstSame).

The stringgrid is updated with Intials and surname, born year (see format on the demo) and salary.
Note the heading and content of the stringgrid.

List box is updated with employees earning the same salary as the employee on the selected line.
Take a look at Figure 7 or demo.

4
Figure 7

You might also like