100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Otro

COS Assignment 1 solution

Puntuación
-
Vendido
4
Páginas
24
Subido en
15-05-2023
Escrito en
2022/2023

This document provides full working solutions and discussions for the assignment. The link to the source code is provided at the end of the document

Institución
Grado












Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
15 de mayo de 2023
Archivo actualizado en
16 de mayo de 2023
Número de páginas
24
Escrito en
2022/2023
Tipo
Otro
Personaje
Desconocido

Temas

Vista previa del contenido

COS3711 2023 ASSIGNMENT 1
DISCUSSION
(with the source code you need)

Crystal Indigo!
Crystal Indigo!
Providing all solutions you need anytime
+27 76 626 8187




***copy and run the code in Qt Creator ***
*** There is a link to the source code at the end of this discussion***
if there is a program that is not running, please contact


Note: do not submit as pdf and change the code where necessary

,Question 1:
Write an application that can be used to keep a list of staff member details. Each staff member
data should include the following:
1. A name
2. A birthdate, and
3. A staff appointment type (one of permanent, part-time, or contract, stored and handled as an
enum).
Include all necessary getter and setter functions. An additional getter can be used to return the
appointment type as a Qstring. The application should allow a user to enter details via a GUI. Also,
once a staff member’s details are entered, they should be saved to a list/container in the application.
The user should be able to write this list to file (in any acceptable, human-readable format) when
needed.
Ensure that you adhere to basic design principles and avoid any anti-patterns in the design of
your solution.

Discussion:
The application consists of three classes: MainWindow, StaffMember, and
StaffListModel. In the initial solution provided, the StaffMember class is responsible for
storing the details of a staff member, including their name, birthdate, and staff appointment type. In
the first part of the solution, the StaffMember class is defined with three private data members -
m_name, m_birthdate, and m_staffAppointment. These data members represent the
name, birthdate, and appointment type of a staff member, respectively.


The StaffMember class also provides public getter and setter functions for each of its private
data members, allowing external code to access and modify the staff member's information.
Additionally, the class provides a function that returns a string representation of the staff member's
information.
Overall, the StaffMember class encapsulates the data and behaviour related to an individual staff
member, providing a clean and modular way to represent and manipulate staff member information
in the application.

,Output when run:

,Source code
//staffmember.h
#ifndef STAFFMEMBER_H
#define STAFFMEMBER_H

#include <QString>
#include <QDate>

enum class AppointmentType {
Permanent,
PartTime,
Contract
};

class StaffMember
{
public:
StaffMember();
StaffMember(const QString& name, const QDate& birthdate, AppointmentType
appointmentType);

QString getName() const;
QDate getBirthdate() const;
AppointmentType getAppointmentType() const;
QString getAppointmentTypeString() const;

private:
QString m_name;
QDate m_birthdate;
AppointmentType m_appointmentType;

};

#endif // STAFFMEMBER_H




//staffmember.cpp
#include "staffmember.h"

StaffMember::StaffMember()
{

}

, StaffMember::StaffMember(const QString& name, const QDate& birthdate,
AppointmentType appointmentType)
: m_name(name), m_birthdate(birthdate), m_appointmentType(appointmentType)
{
}

QString StaffMember::getName() const
{
return m_name;
}

QDate StaffMember::getBirthdate() const
{
return m_birthdate;
}

AppointmentType StaffMember::getAppointmentType() const
{
return m_appointmentType;
}

QString StaffMember::getAppointmentTypeString() const
{
switch (m_appointmentType) {
case AppointmentType::Permanent:
return "Permanent";
case AppointmentType::PartTime:
return "Part-Time";
case AppointmentType::Contract:
return "Contract";
default:
return "";
}
}

//stafflistmodel.h
#ifndef STAFFLISTMODEL_H
#define STAFFLISTMODEL_H

#include <QAbstractListModel>
#include <QList>
#include "staffmember.h"

class StaffListModel : public QAbstractListModel
{
Q_OBJECT
public:
StaffListModel();
StaffListModel(QObject *parent = nullptr);
$13.65
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

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.
CrystalIndigo University of South Africa (Unisa)
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
486
Miembro desde
5 año
Número de seguidores
226
Documentos
73
Última venta
2 meses hace
CrystalIndigo Solutions

providing all solutions to all computer science modules

4.1

51 reseñas

5
27
4
13
3
6
2
1
1
4

Recientemente visto por ti

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