100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS3711 Assignment 3 (COMPLETE ANSWERS) 2024 - DUE 9 September 2024 £2.24   Add to cart

Exam (elaborations)

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

 20 views  0 purchase
  • Module
  • Institution
  • Book

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...

[Show more]

Preview 3 out of 21  pages

  • June 25, 2024
  • 21
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
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.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller iStudy. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £2.24. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79223 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£2.24
  • (0)
  Add to cart