• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 5 fuera de 23 páginas
Examen

COS3711 Assignment 1 Due Year 2026

Document preview thumbnail
Vista previa 5 fuera de 23 páginas

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.

Vista previa del contenido

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

Libro relacionado
 image
W. Richard Stevens, Stephen A. Rago Advanced Programming in the UNIX Environment
Editorial: 2013 ISBN: 9780321637734 Edición: Desconocido

Información del documento

Subido en
16 de febrero de 2026
Número de páginas
23
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$4.91

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
BeeNotes
4.1
(40)
Vendido
352
Seguidores
0
Artículos
1012
Última venta
1 semana hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes