100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Overig

COS Assignment 1 solution

Beoordeling
-
Verkocht
4
Pagina's
24
Geüpload op
15-05-2023
Geschreven in
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

Instelling
Vak












Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
15 mei 2023
Bestand laatst geupdate op
16 mei 2023
Aantal pagina's
24
Geschreven in
2022/2023
Type
Overig
Persoon
Onbekend

Onderwerpen

Voorbeeld van de inhoud

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

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
CrystalIndigo University of South Africa (Unisa)
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
486
Lid sinds
5 jaar
Aantal volgers
226
Documenten
73
Laatst verkocht
1 maand geleden
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 beoordelingen

5
27
4
13
3
6
2
1
1
4

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen