COS3711 2024 Assignment 1

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

COS3711/Assignment 1/2024

Assignment Tutorial Letter 2024

Advanced Programming
COS3711

Year module

Computer Science Department

Assignment 1 Questions

BARCODE

1
COS3711/Assignment 1/2024
Assignment 1

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 classes (as necessary, remembering to avoid any anti-patterns) that will manage software
review data. The data itself consists of
• the name of the software,
• the date of the review, and
• an indication of whether it is recommended or not.

You should create a graphical user interface that allows a user to enter the data. Data should be
stored in an appropriate container (allowing for several reviews to be recorded), and be printed to a
console window when required.

Test your code by adding at least 3 pieces of data. Below is an example of a possible interface.
Question 2

Extend Question 1 so that it uses reflective programming techniques to access the data members of
the object that holds the review data. Write another display function that does not use any public
accessor functions (or a toString() function) to get access to the review data. Also add a button to
display the review detail to the application window (so that the program now can print to the
console or GUI window).
When displaying the data to the application window, you cannot assume that you know beforehand
how many properties there are, what they are called, or of what type they are. You need to loop
through the properties and using reflective programming techniques, display the data to the
application window.

HINT: You will need to use QVariant.

Question 3
Use Qt’s model/view framework to store and display music CD information. The following
information should be stored in the model (a QStandardItemModel):
• composer,
• album name,
• replacement value, and
• a rating (out of 100).
The information should be displayed in a table.

The following functionality should be included.


• There should be a header row.
• The user should be able to add rows of data to the model.
• The replacement value should always display the cents (even as .00).
• Use a delegate to display the rating as a horizontal bar. This column should take up
all the remaining space available.
• The user should be able to sort the data by clicking on the column header on which
the sorting should be implemented.
• Where the replacement value is greater than or equal to R200, the row should be
made a different colour. Note that this colour should also change if the user edits a
replacement value (and it should return to the normal colour if the value drops below
R200).
• The user should be able to delete a row of data.
Here is an example of the interface.
Question 4

Write an application that uses regular expressions to check for telephone numbers and email
addresses 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.
• The file should be displayed in the GUI.
• The telephone numbers and email addresses should be highlighted/emphasized in
some way in the text.

An email address can be identified by a single @ symbol in the address; telephone numbers could
be from any of the following formats:
• 000-000-0000
• 000-0000000
• 0000000000
• (000)000-0000
• (000)0000000
You may assume that the email addresses and telephone numbers are free standing, that is, they do
not have brackets (or any other character) around them.

See an example below.

HINT: Consider using the QTextDocument, and QTextCursor classes.

© Unisa
2024

You might also like