100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS Assignment 1 solution $12.53   Add to cart

Other

COS Assignment 1 solution

 162 views  4 purchases
  • Course
  • Institution

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

Last document update: 1 year ago

Preview 5 out of 24  pages

  • May 15, 2023
  • May 16, 2023
  • 24
  • 2022/2023
  • Other
  • Unknown
avatar-seller
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);

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 or Stuvia-credit 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 CrystalIndigo. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

73918 documents were sold in the last 30 days

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

Start selling
$12.53  4x  sold
  • (0)
  Add to cart