,COS3711 Assignment 3 (COMPLETE ANSWERS) 2024 - DUE
9 September 2024 ; 100% TRUSTED workings, explanations and
solutions.
Question 1 Write an application that can be used to process Staff
member details. The fields that should be stored include: • A
name, • A birthdate, and • A staff appointment type (one of
permanent, part-time, or contract, stored as an enum). Note that
the getter and setter for this data member may be done using a
QString. Downloaded by Corona Virus () lOMoARcPSD| The
application should allow a user to enter details via GUI. Also,
once a staff member’s details are entered, they should be written
to file (in any acceptable format) and stored in a container in the
application. Ensure that you adhere to basic design principles, and
avoid any anti-patterns in the design of your solution
Sure, here's a simple application using Python and PyQt5 for the
GUI. The application will allow users to enter staff member
details and store them in a file and a container.
First, you'll need to install PyQt5. You can install it using pip if
you haven't already:
bash
Copy code
pip install PyQt5
Here's the full implementation:
, python
Copy code
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel,
QLineEdit, QComboBox, QPushButton, QVBoxLayout,
QMessageBox
from PyQt5.QtCore import QDate
from PyQt5.QtGui import QIntValidator
import json
class StaffMember:
def __init__(self, name, birthdate, appointment_type):
self.name = name
self.birthdate = birthdate
self.appointment_type = appointment_type
def to_dict(self):
return {
"name": self.name,
"birthdate": self.birthdate,
"appointment_type": self.appointment_type
}
class StaffApp(QWidget):
def __init__(self):
super().__init__()
self.staff_members = []
self.initUI()
def initUI(self):