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 5 out of 23 pages
Exam (elaborations)

COS3711 Assignment 1 Due Year 2026

Document preview thumbnail
Preview 5 out of 23 pages

COMPREHENSIVE ANSWERS. DISTINCTION GUARANTEED This 100% exam-ready assignment come with expert-verified answers, in-depth explanations, and reliable references, meticulously crafted to ensure you grasp every concept with ease. Designed for clarity and precision, these fully solved material is your key to mastering any subject and acing your exams.

Content preview

COS3711
Assignment 1
Due 2026

,Question 1


Vehicle hierarchy and Qt parent–child list


1.1 Interpretation of the requirements


The task is to design a console-based vehicle management application using
sound object oriented principles and Qt features. The specification requires
the following:


* Each vehicle must have:
* a model (text)
* a year (integer with a reasonable range)
* There are two specialised vehicle types:


* Passenger vehicles with a passenger count
* Transport vehicles with a carrying capacity in kilograms
* Vehicles created without explicit values must use sensible defaults
* All appropriate getters and setters must be provided
* A function must output vehicle details
* A list of vehicles must be implemented using Qt’s parent–child facility
* The program must create several vehicles (including one using the default
constructor), add them to the list, and print them to the console


To support reflection later in Question 2, it is appropriate to design all
classes as subclasses of QObject and expose their data through Q_PROPERTY.

,1.2 Class design overview


A clean design is a small inheritance hierarchy:


* Vehicle (base class)
* PassengerVehicle (derived class)
* TransportVehicle (derived class)


This avoids redundant code and follows OOP principles such as reuse and
polymorphism.


Vehicle (Base Class)


Superclass: QObject
Attributes:


* QString model
* int year


Operations:


* Constructors with default values
* Getter and setter for model
* Getter and setter for year (with validation)
* Virtual function describe() to output details

,PassengerVehicle (Derived from Vehicle)


Additional attribute:


* int passengerCount


Operations:


* Getter and setter for passenger count
* Override describe()


TransportVehicle (Derived from Vehicle)


Additional attribute:


* double capacityKg


Operations:


* Getter and setter for capacity
* Override describe()


All classes inherit QObject, include Q_OBJECT, and define Q_PROPERTY entries
so their properties can be inspected reflectively.

, 1.3 Base Vehicle class design


The Vehicle class stores common data and ensures values remain valid.


```cpp
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(const QString &model = "Unknown",
int year = QDate::currentDate().year(),
QObject *parent = nullptr)
: QObject(parent), m_model(model), m_year(year)
{
setYear(m_year); // ensure validation
}


QString model() const { return m_model; }
void setModel(const QString &model) { m_model = model; }


int year() const { return m_year; }
void setYear(int year) {
int current = QDate::currentDate().year();
if (year < 1886 || year > current + 1)
m_year = current;
else
m_year = year;
}


virtual QString describe() const {
return QString("Model: %1, Year: %2").arg(m_model).arg(m_year);

Connected book
 image
W. Richard Stevens, Stephen A. Rago Advanced Programming in the UNIX Environment
Publisher: 2013 ISBN: 9780321637734 Edition: Unknown

Document information

Uploaded on
February 16, 2026
Number of pages
23
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
R80,74

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.
BeeNotes
4,1
(40)
Sold
338
Followers
0
Items
981
Last sold
3 hours ago




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