• ¿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 6 fuera de 33 páginas
Examen

COS3711 Assignment 3 2025 (Comprehensive Code) Due Year 2025

Document preview thumbnail
Vista previa 6 fuera de 33 páginas

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.

Vista previa del contenido

COS3711
Assignment 3
Due Year 2025

,COS3711: Advanced Programming

Assignment 3 2025



Table of contents

1. Summary of objectives

2. Design overview (classes, relationships, patterns)

3. Source-code structure and CMake outline

4. Class skeletons (headers + short comments)

➢ Container hierarchy (abstract base, Box, Cylinder)

➢ ContainerFactory (Factory Method)

➢ Pallet and PalletManager

➢ Memento for backup/restore

➢ Models for Qt (Unallocated container list and Pallet model)

5. GUI skeleton (QMainWindow, tabs, widgets, actions)

6. XML serialization (QXmlStreamWriter) and parsing (DOM / QXmlStreamReader)

7. Threaded serialization worker (Qt threading) and TCP client (send XML to
127.0.0.1:6164)

8. TCP server (separate project) — listen, parse XML, validate codes, update
model/view

9. Notes on memory management, patterns, validation, and testing

10. Minimal CMakeLists.txt examples

11. References

,1. Summary of objectives



Produce a complete solution that:

• Models containers (Box, Cylinder) with code, weight, and computed volume.

• Only allows concrete instantiation of Box or Cylinder.

• Displays unallocated containers using Qt model/view.

• Moves containers to pallets identified by arbitrary numbers.

• Supports in-memory backup and restore of unallocated containers (no pointer-
only backups).

• Serializes pallet list to XML, sends XML to a TCP server (127.0.0.1:6164) in a
thread, and shows XML in the UI.

• Implements a separate TCP server project that receives XML, validates container
codes via regex, shows **** for invalid codes, and displays container data via
model/view.



2. Design overview



Key classes and responsibilities (high-level)

• Container (abstract): holds code, weight, virtual volume() and virtual
toXml(QXmlStreamWriter&).

• Box and Cylinder: implement volume() and serialization details.

• ContainerFactory: create Box or Cylinder instances and generate container
codes.

• Pallet: holds container pointers, computes total weight and total volume.

, • PalletManager: map of pallet number → Pallet pointer; responsible for
serialization of all pallets.

• Memento / BackupManager: stores serializable snapshots of unallocated
containers (not raw pointers).

• ContainerListModel (subclass of QAbstractListModel): model for unallocated
container codes.

• PalletModel / PalletsTreeModel (e.g., QStandardItemModel): model for pallet
display.

• MainWindow (QMainWindow): provides GUI and orchestrates actions.

• XmlSerializerWorker (runs in a QThread): produces XML and uses TcpSender to
deliver it.

• TcpSender (client object): connects to 127.0.0.1:6164 and sends XML bytes.

• TcpServerApp (separate Qt app): listens on 6164, parses XML, validates codes
via regex, updates a QStandardItemModel.

Design patterns used

• Factory Method for creating Box/Cylinder.

• Memento for backup/restore of unallocated containers.

• Model–View for UI lists (Qt QAbstractItemModel).

• RAII / parent ownership of Qt widgets to manage memory.

• Worker thread pattern for background serialization and network IO.

Rationale: The Factory centralizes code format and serial numbering. The Memento
avoids pointer resurrection while allowing in-memory rollback. Qt model/view separates
data and presentation, enabling responsive UI updates.

,3. Source-code layout

COS3711_A3/
├─ app/ # main application (GUI)
│ ├─ include/
│ │ ├─ container.h
│ │ ├─ box.h
│ │ ├─ cylinder.h
│ │ ├─ containerfactory.h
│ │ ├─ pallet.h
│ │ ├─ palletmanager.h
│ │ ├─ memento.h
│ │ ├─ containerlistmodel.h
│ │ ├─ xmlserializerworker.h
│ │ └─ tcpsender.h
│ ├─ src/
│ │ └─ *.cpp
│ ├─ resources/ (icons)
│ └─ CMakeLists.txt
├─ server/ # TCP server project
│ ├─ src/
│ └─ CMakeLists.txt
└─ CMakeLists.txt

, 4. Class skeletons and brief explanation

4.1 container.h (abstract base)



// include/container.h
#pragma once

#include <QString>
#include <QXmlStreamWriter>
#include <memory>

class Container {
public:
explicit Container(QString code, double weight)
: m_code(std::move(code)), m_weight(weight) {}
virtual ~Container() = default;

QString code() const { return m_code; }
double weight() const { return m_weight; }
void setWeight(double w) { m_weight = w; }

// volume must be integer per spec; return as integer
virtual int volume() const = 0;
virtual void toXml(QXmlStreamWriter& writer) const = 0;

protected:
QString m_code;
double m_weight;
};
using ContainerPtr = std::unique_ptr<Container>;

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
11 de septiembre de 2025
Número de páginas
33
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
353
Seguidores
0
Artículos
1012
Última venta
1 día 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