You are on page 1of 4

COS3711/Assignment 3/2024

Assignment Tutorial Letter 2024

Advanced Programming

COS3711

Year module

Computer Science Department

Assignment 3 Questions

BARCODE
Assignment 3
1. Introduction
Please use CMake (and not qmake) when setting up your assignment projects.
Qt Designer should not be used to design user interfaces, and you are expected to manually set up
GUIs to ensure that you properly handle memory using Qt’s parent-child functionality.

Good programming practices should be followed.

Follow standard naming conventions: class names start with a capital letter, variable and function
names start with a lowercase letter, using camelCase for names made up of multiple words.

Ensure consistent code layout and use of blank lines. Use


forward class declarations in header files.

Use initialiser lists in constructors.

Have proper GUI management: setting cursor focus, sequential tabbing, clearing input widgets
(like text input fields being cleared and spin boxes being returned to some default value), and
enabling and disabling buttons as appropriate.

Provide appropriate user feedback.

Your code should build and run without any warnings.

2. Questions
Question 1
Write an application that can be used to process Staff member details. The fields that should be
stored include:
• A name,
• A birthdate, and
• A staff appointment type (one of permanent, part-time, or contract, stored as an
enum). Note that the getter and setter for this data member may be done using a
QString.
The application should allow a user to enter details via GUI. Also, once a staff member’s details
are entered, they should be written to file (in any acceptable format) and stored in a container in
the application.
Ensure that you adhere to basic design principles, and avoid any anti-patterns in the design of your
solution.

Question 2
Taking Question 1 a step further, make all the getters and setters (including any toString()
functions) that give access to the data members name, birthdate and staff type private. Then make
the necessary changes so that your application uses reflective programming techniques to access
the data members in the object that holds the staff data when writing to file.
Note that you cannot assume that you know beforehand how many properties there are, what they
are called, or of what type they are. You will need to be more specific when handling the enum,
though (and in this case you can accept that you know what its values are); also, you will have to
move away from using a QString for the enum here.

HINT: You will need to use QVariant.

Question 3
Write an application that uses regular expressions to check for problems in a text file provided by
a user. The following functionality should be included.
• The user should be able to select the file to check using a standard file open dialog
box.
• There should be some way of indicating that the file has been loaded.
• Problematic words should be displayed, giving the line number and the word
number in the line as well.
The following problematic words should be flagged (using regular expressions to identify such
words):
• Words with a number anywhere in the word
• Words with a capital letter in any position apart from at the start of the word.
• Words that have any special characters (like #, *, /, @, ^, and so on) as part of the
word. Note that a – is acceptable.

The screenshot below gives examples of words that should be flagged.

Question 4
Write an application that can check passwords (using regular expressions) and indicate if they
are acceptable or not acceptable according to the following rules.
• It must be at least 5 characters in length.
• It must contain at least one capital/uppercase letter.
• It must contain at least one lowercase letter.
• It must contain at least one number/digit.
• It may not contain any repeating characters (that is, “ele” is acceptable, but “eel”
is not).
The application should indicate as you type whether the text provided is acceptable and should
not rely on the user having to press a button to check acceptability.

© Unisa

2024

You might also like