Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 12 pages
Exam (elaborations)

MAT3701 Assignment 4 2026 - Due 4 September 2026

Document preview thumbnail
Preview 2 out of 12 pages

MAT3701 Assignment 4 2026 - Due 4 September 2026

Content preview

COS3711
ASSIGNMENT 1 2026
DUE: 15 MAY 2026

, Question 1
For this question you need to ensure that you design the appropriate classes
needed to address the specification below.

Create a console application to handle vehicle 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.




We define a base Vehicle class and two subclasses
( PassengerVehicle and TransportVehicle ) using Qt’s object model. Each class
inherits QObject (to leverage Qt’s meta-object system) and uses the Q_OBJECT macro. Key
member variables are exposed as Qt properties with Q_PROPERTY to enable reflection
(needed later). For example, Vehicle has model (QString) and year (int),
while PassengerVehicle adds passengerCount and TransportVehicle adds cargoCapaci
ty . Constructors initialize defaults; getters/setters manipulate these properties. By passing

a QObject *parent to each constructor and calling QObject(parent) , we build a parent–
child hierarchy. Qt automatically adds a created object to its parent’s children() list and
takes ownership (deleting children in the parent’s destructor) . This means we can
keep a “root” QObject whose children are all vehicle instances, avoiding manual memory
management. Finally, each class provides a display() method to print its details.




C++


#include <QObject>
#include <QString>
#include <QDebug>

class Vehicle : public QObject {
Q_OBJECT
Q_PROPERTY(QString model READ model WRITE setModel)
Q_PROPERTY(int year READ year WRITE setYear)
public:
explicit Vehicle(QObject *parent = nullptr)
: QObject(parent), m_model("Unknown"), m_year(0) {}
// Accessors
QString model() const { return m_model; }
int year() const { return m_year; }
void setModel(const QString &m) { m_model = m; }
void setYear(int y) { m_year = y; }
// Display details
void display() const {
qDebug() << "Vehicle:" << m_model << ", Year:" << m_year;
}
private:
QString m_model;
int m_year;
};

Document information

Uploaded on
February 23, 2026
File latest updated on
August 5, 2026
Number of pages
12
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$4.78

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Whatsapbuddiez
3.9
(53)
Sold
749
Followers
172
Items
224
Last sold
12 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions