PDA

View Full Version : Designing appropriate classes



NemutandaniRodney
4th September 2020, 13:20
Good day,

Can someone please assist me with the following questions:

1. Create a console application to handle graph details. Considering the required functionality that is required
and OOP design principles (avoiding anti-patterns and having minimal redundant code), create and
implement the appropriate classes necessary to achieve the following.
? A node in the graph would be made up of a label (the name of the node), an (x, y) coordinate indicating
its position, and an indication of its shape. Provide all the necessary getters and setters.
? The application should include a list of nodes.
? The application should also have a list of paths where the user can add paths between labelled nodes
indicating the type of path (for example, --, ->, <->, or <-). It is clearly necessary to check that the
labels exist before adding a path between them.
? The application should be able to output to the console a list of paths in the following format:
a [Square at (1, 1)] -> b [Circle at (5, 5)]
? Test your solution by creating some nodes, adding them to the list of nodes, and then adding some
paths (some acceptable, some not). Finally, display the path list.

2. This question focusses on the concepts of reflection and meta-objects.
Extend the application you wrote in question 1 by fully serialising the node and path lists. Note the following
requirements.
? Both writer and reader parts of the Serializer should be implemented, serialising to a single file.
? Any text-based file format may be used.
? When writing, use reflection and the meta-objects as far as possible.
? When reading, the various lists should re-created and the data displayed again (to confirm that the
data was successfully serialised).

3. Rewrite the InputForm class in Chapter 14 to include an additional QLineEdit to enter a student
number. A QRegExpValidator should be attached to this QLineEdit so that it only allows a user to
enter a single, uppercase alphabetic character, followed by a 4 or 5 digit number that does not begin with
a 0. The result of the computation should be displayed in a QMessageBox with the student number
(Example: ‘Total Pay for the student S5666 is 183.75’) instead of displaying the message on the input
interface.

4. Write a file system browser that allows a user to do the following:
? Use the QFileSystemModel to model the directory structure on your computer.
? Browse the file/folder structure (using a QTreeView)
? Display the following information on any file/folder clicked on: name, path, size (for files), and whether
it is a file or a folder.
Create a folder (using a ‘New folder’ button) as a sub-directory in the selected directory
? Rename an existing file/directory (using the inherent ability of the model class)
? Delete a file/directory (using a ‘Delete’ button) – ensure that you check whether the file/folder should
be deleted, and also ensure that the information displayed remains current once the file/folder has
been deleted.

d_stranz
4th September 2020, 17:02
Can someone please assist me with the following questions

No, I think you should learn to solve your homework problems on your own instead of posting the assignment here and expecting us to do your homework for you.

Some suggestions:

Problem 1: Since it is a console app, you do not need any user interface other than command line input and output. So stdin / stdout or cin / cout will work. You'll need to define some commands the user can type to display the list of node and edges, etc. You will likely want to implement a Node and an Edge class. The problem doesn't state whether the graph is allowed to have cycles (nodes connected by edges that form a loop). If it does, you will need to make sure you don't get stuck in an infinite loop as you traverse the graph printing nodes and edges.

Problem 2: Use XML. Qt has a QDomDocument architecture for this.

Problem 3: There are plenty of examples in the Qt distribution that show how to use all of these classes.

Problem 4: Likewise.