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 4 out of 19 pages
Exam (elaborations)

COS3711 Assignment 1 2026 Due on Year 2026.

Document preview thumbnail
Preview 4 out of 19 pages

DISTINCTION GUARANTEED This 100% exam-ready assignment offers expertly verified answers, comprehensive explanations, and credible academic references—meticulously developed to ensure a clear understanding of every concept. Designed with clarity, precision, and academic integrity, this fully solved resource is your key to mastering the subject and excelling in your assessments.

Content preview

Advanced Programming


COS3711
Assignment 1
Due 2026

,Question 1


Vehicle hierarchy and Qt parent–child list


Interpretation of the requirements


The key requirements are:


* Every vehicle has a model and a year.
* The year must be reasonable.
* Two specialised types exist:
* Passenger vehicles with a passenger count
* Transport vehicles with carrying capacity in kilograms
* Objects created without details must use sensible defaults.
* All getters and setters must be provided.
* A function must output vehicle details.
* The list must use Qt parent–child ownership rather than a container.
* The program must create and print multiple vehicles, including one created
with the default constructor.


To support Question 2 later, all classes should inherit from QObject and
expose properties using Q_PROPERTY.




Class design


A clean inheritance hierarchy avoids redundancy and promotes reuse.

,Base class: Vehicle


Responsibilities:


* Store shared attributes
* Provide validation logic
* Enable polymorphic output


Attributes:


* QString model
* int year


Operations:


* Constructors with defaults
* Getters and setters
* Validation of year
* Virtual describe() function


```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)
{
setYear(year);

, }


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);
}


private:
QString m_model;
int m_year;
};
```


Key design justification:


* Centralised validation prevents duplicated logic.
* Defaults ensure valid objects even when using empty constructors.
* Q_PROPERTY enables reflection for Question 2.

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
19
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.
LectureLab
3,6
(86)
Sold
689
Followers
188
Items
1561
Last sold
3 days 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