100% tevredenheidsgarantie Direct beschikbaar na betaling Zowel online als in PDF Je zit nergens aan vast
logo-home
COS3711 Assignment 3 (COMPLETE ANSWERS) 2024 - DUE 9 September 2024 $2.85   In winkelwagen

Tentamen (uitwerkingen)

COS3711 Assignment 3 (COMPLETE ANSWERS) 2024 - DUE 9 September 2024

 20 keer bekeken  0 keer verkocht
  • Vak
  • Instelling
  • Boek

COS3711 Assignment 3 (COMPLETE ANSWERS) 2024 - DUE 9 September 2024 ; 100% TRUSTED workings, explanations and solutions. for assistance Whats-App 0.6.7..1.7.1..1.7.3.9 ........... Question 1 Write an application that can be used to process Staff member details. The fields that should be stored in...

[Meer zien]

Voorbeeld 3 van de 21  pagina's

  • 25 juni 2024
  • 21
  • 2023/2024
  • Tentamen (uitwerkingen)
  • Vragen en antwoorden
avatar-seller
COS3711
Assignment 3 2024
Detailed Solutions, References & Explanations

Unique number:

Due Date: 9 September 2024
QUESTION 1

### Staff.h
/// cpp
#ifndef STAFF_H
#define STAFF_H

#include <QString>
#include <QDate>

class Staff {
public:
enum class AppointmentType { Permanent, PartTime, Contract };

Staff(const QString& name, const QDate& birthdate, AppointmentType
type);

// Getters
QString getName() const;
QDate getBirthdate() const;
QString getAppointmentType() const;

// Setters
void setName(const QString& name);
void setBirthdate(const QDate& birthdate); Terms of use
void setAppointmentType(const QString& type);
By making use of this document you agree to:
• Use this document as a guide for learning, comparison and reference purpose,
• Not to duplicate, reproduce and/or misrepresent the contents of this document as your own work,
• Fully accept the consequences should you plagiarise or misuse this document.


Disclaimer
Extreme care has been used to create this document, however the contents are provided “as is” without
any representations or warranties, express or implied. The author assumes no liability as a result of
reliance and use of the contents of this document. This document is to be used for comparison, research
and reference purposes ONLY. No part of this document may be reproduced, resold or transmitted in any
form or by any means.

, +27 67 171 1739

QUESTION 1

Sure, let me provide a high-level design and implementation outline for the application
using C++ with the Qt framework. We'll create the necessary classes to handle this
functionality while ensuring proper separation of concerns.



### High-Level Class Structure



1. Staff class: Represents an individual staff member.

2. StaffList class: Manages a list of Staff objects.

3. StaffWriter class: Handles writing Staff objects to a file.

4. MainWindow class: Provides GUI for user interaction.



### Staff.h
/// cpp
#ifndef STAFF_H
#define STAFF_H

#include <QString>
#include <QDate>

class Staff {
public:
enum class AppointmentType { Permanent, PartTime, Contract };

Staff(const QString& name, const QDate& birthdate,
AppointmentType type);

// Getters
QString getName() const;
QDate getBirthdate() const;
QString getAppointmentType() const;

// Setters
void setName(const QString& name);
void setBirthdate(const QDate& birthdate);
void setAppointmentType(const QString& type);

private:
QString name;
QDate birthdate;
AppointmentType appointmentType;
Disclaimer
Extreme care has been used to create this document, however the contents are provided “as is” without
any representations or warranties, express or implied. The author assumes no liability as a result of
reliance and use of the contents of this document. This document is to be used for comparison, research
and reference purposes ONLY. No part of this document may be reproduced, resold or transmitted in any
form or by any means.

, +27 67 171 1739


// Static method to convert between QString and AppointmentType
static QString appointmentTypeToString(AppointmentType type);
static AppointmentType stringToAppointmentType(const QString&
type);
};

#endif // STAFF_H
///


### Staff.cpp
/// cpp
#include "Staff.h"

Staff::Staff(const QString& name, const QDate& birthdate,
Staff::AppointmentType type)
: name(name), birthdate(birthdate), appointmentType(type) {}

// Getters
QString Staff::getName() const { return name; }
QDate Staff::getBirthdate() const { return birthdate; }
QString Staff::getAppointmentType() const { return
appointmentTypeToString(appointmentType); }

// Setters
void Staff::setName(const QString& name) { this->name = name; }
void Staff::setBirthdate(const QDate& birthdate) { this->birthdate =
birthdate; }
void Staff::setAppointmentType(const QString& type) { this-
>appointmentType = stringToAppointmentType(type); }

QString Staff::appointmentTypeToString(Staff::AppointmentType type)
{
switch(type) {
case AppointmentType::Permanent: return "Permanent";
case AppointmentType::PartTime: return "Part-time";
case AppointmentType::Contract: return "Contract";
default: return "";
}
}

Staff::AppointmentType Staff::stringToAppointmentType(const QString&
type) {
if (type == "Permanent") return AppointmentType::Permanent;
if (type == "Part-time") return AppointmentType::PartTime;
if (type == "Contract") return AppointmentType::Contract;
throw std::invalid_argument("Invalid appointment type");
}
///


### StaffList.h
/// cpp
#ifndef STAFFLIST_H
Disclaimer
Extreme care has been used to create this document, however the contents are provided “as is” without
any representations or warranties, express or implied. The author assumes no liability as a result of
reliance and use of the contents of this document. This document is to be used for comparison, research
and reference purposes ONLY. No part of this document may be reproduced, resold or transmitted in any
form or by any means.

Voordelen van het kopen van samenvattingen bij Stuvia op een rij:

Verzekerd van kwaliteit door reviews

Verzekerd van kwaliteit door reviews

Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!

Snel en makkelijk kopen

Snel en makkelijk kopen

Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.

Focus op de essentie

Focus op de essentie

Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper iStudy. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor $2.85. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 71184 samenvattingen verkocht

Opgericht in 2010, al 14 jaar dé plek om samenvattingen te kopen

Start met verkopen

Laatst bekeken door jou


$2.85
  • (0)
  Kopen