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
Exam (elaborations)

COS3711 ASSIGNMENT 1 2026 - DISTINCTION | DUE 15 MAY 2026

Rating
-
Sold
3
Pages
12
Grade
A+
Uploaded on
23-02-2026
Written in
2025/2026

COS3711 Assignment 1 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. • A vehicle needs to have a model and a year (which should be a reasonable value). There are basically 2 types of vehicles: passenger vehicles (that can carry a specified number of passengers) and transport vehicles (that have a set carrying capacity expressed in kilograms). Vehicles that are created without the necessary details should have default values. • Ensure all appropriate getters and setters are included. • Include a function that can output the details of the vehicle. • Use Qt’s parent-child facility to implement a list of vehicles.

Show more Read less

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
Number of pages
12
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
R75,00
Get access to the full document:

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

Get to know the seller

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 Teachme2-tutor
View profile
Follow You need to be logged in order to follow users or courses
Sold
708
Member since
2 year
Number of followers
171
Documents
208
Last sold
3 days ago
Wh@tsappbuddiez

At buddies, we are dedicated to providing top-quality tutoring services tailored to meet your academic needs. Our team of experienced tutors is committed to helping you achieve success in all subject modules. Whether you\\\'re struggling with complex concepts or aiming to excel in your studies, we\\\'re here to guide you every step of the way. Why Choose Us? Experienced Tutors: Our tutors are highly qualified professionals with a passion for teaching and a track record of success. Personalized Approach: We understand that every student is unique, which is why we customize our teaching methods to suit your learning style and pace. Interactive Learning: Engage in dynamic and interactive learning sessions designed to make studying enjoyable and effective. Flexible Scheduling: We offer flexible scheduling options to accommodate your busy lifestyle and ensure convenient access to tutoring support.

Read more Read less
3,9

51 reviews

5
25
4
10
3
7
2
3
1
6

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT 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