You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
325 lines
9.1 KiB
Python
325 lines
9.1 KiB
Python
## Capstone Specifications
|
|
|
|
# 1. In the s05 folder, create an "activity" folder, and inside it, create an "activity.py" file.
|
|
# 2. Create a **Person** class, which is an **abstract class**, and includes the following methods:
|
|
# - getFullName() method
|
|
# - addRequest() method
|
|
# - checkRequest() method
|
|
# - addUser() method
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
class Person(ABC):
|
|
@abstractmethod
|
|
def getFullName(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def addRequest(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def checkRequest(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def addUser(self):
|
|
pass
|
|
|
|
# 3. Create an **Employee** class that **inherits from Person** class, with the following properties and methods:
|
|
# - Properties (Define the properties as **protected**, and implement **getters and setters** for each.)
|
|
# - firstName
|
|
# - lastName
|
|
# - email
|
|
# - department
|
|
|
|
class Employee(Person):
|
|
def __init__(firstName, lastName, email, department):
|
|
super().__init__()
|
|
self._firstName = firstName
|
|
self._lastName = lastName
|
|
self._email = email
|
|
self._department = department
|
|
|
|
# getters and setters
|
|
def get_firstName(self):
|
|
return self._firstName
|
|
|
|
def get_lastName(self):
|
|
return self._lastName
|
|
|
|
def get_email(self):
|
|
return self._email
|
|
|
|
def get_department(self):
|
|
return self._department
|
|
|
|
def set_firstName(self, firstName):
|
|
self._firstName = firstName
|
|
|
|
def set_lastName(self, lastName):
|
|
self._lastName = lastName
|
|
|
|
def set_email(self, email):
|
|
self._email = email
|
|
|
|
def set_department(self, department):
|
|
self._department = department
|
|
|
|
# - Abstract methods
|
|
# - getFullName() - outputs the full name
|
|
# - addRequest() - outputs "Request has been added"
|
|
# - checkRequest() - pass
|
|
# - addUser() - pass
|
|
|
|
def getFullName(self):
|
|
return f"{self._firstName } {self._lastName}"
|
|
|
|
def addRequest(self):
|
|
return "Request has been added"
|
|
|
|
def checkRequest(self):
|
|
pass
|
|
|
|
def addUser(self):
|
|
pass
|
|
|
|
# - Custom methods
|
|
# - login() - outputs "<Email> has logged in"
|
|
# - logout() - outputs "<Email> has logged out"
|
|
|
|
def login(self):
|
|
return f"{self._email} has logged in"
|
|
|
|
def logout(self):
|
|
return f"{self._email} has logged out"
|
|
|
|
# 4. Create a **TeamLead** class that **inherits from Person** class with the following properties and methods:
|
|
# - Properties (Define the properties as **protected**, and implement **getters and setters** for each.)
|
|
# - firstName
|
|
# - lastName
|
|
# - email
|
|
# - department
|
|
# - members - empty list
|
|
|
|
class TeamLead(Person):
|
|
def __init__(self, firstName, lastName, email, department):
|
|
super().__init__()
|
|
self._firstName = firstName
|
|
self._lastName = lastName
|
|
self._email = email
|
|
self._department = department
|
|
self._members = []
|
|
|
|
# getters and setters
|
|
def get_firstName(self):
|
|
return self._firstName
|
|
|
|
def get_lastName(self):
|
|
return self._lastName
|
|
|
|
def get_email(self):
|
|
return self._email
|
|
|
|
def get_department(self):
|
|
return self._department
|
|
|
|
def get_members(self):
|
|
return self._members
|
|
|
|
def set_firstName(self, firstName):
|
|
self._firstName = firstName
|
|
|
|
def set_lastName(self, lastName):
|
|
self._lastName = lastName
|
|
|
|
def set_email(self, email):
|
|
self._email = email
|
|
|
|
def set_department(self, department):
|
|
self._department = department
|
|
|
|
# - Abstract methods
|
|
# - getFullName() - outputs the full name
|
|
# - addRequest() - pass
|
|
# - checkRequest() - outputs "Request has been checked"
|
|
# - addUser() - pass
|
|
|
|
def getFullName(self):
|
|
return f"{self._firstName } {self._lastName}"
|
|
|
|
def addRequest(self):
|
|
pass
|
|
|
|
def checkRequest(self):
|
|
return "Request has been checked"
|
|
|
|
def addUser(self):
|
|
pass
|
|
|
|
# - Custom methods
|
|
# - login() - outputs "<Email> has logged in"
|
|
# - logout() - outputs "<Email> has logged out"
|
|
# - addMember() - adds an employee to the members list
|
|
|
|
def login(self):
|
|
return f"{self._email} has logged in"
|
|
|
|
def logout(self):
|
|
return f"{self._email} has logged out"
|
|
|
|
def addMember(self, teamMember):
|
|
self._members.append(teamMember)
|
|
|
|
# 5. Create an **Admin** class the **inherits from Person** class with the following properties and methods:
|
|
# - Properties (Define the properties as **protected**, and implement **getters and setters** for each.)
|
|
# - firstName
|
|
# - lastName
|
|
# - email
|
|
# - department
|
|
|
|
class Admin(Person):
|
|
def __init__(self, firstName, lastName, email, department):
|
|
super().__init__()
|
|
self._firstName = firstName
|
|
self._lastName = lastName
|
|
self._email = email
|
|
self._department = department
|
|
|
|
# getters and setters
|
|
def get_firstName(self):
|
|
return self._firstName
|
|
|
|
def get_lastName(self):
|
|
return self._lastName
|
|
|
|
def get_email(self):
|
|
return self._email
|
|
|
|
def get_department(self):
|
|
return self._department
|
|
|
|
def set_firstName(self, firstName):
|
|
self._firstName = firstName
|
|
|
|
def set_lastName(self, lastName):
|
|
self._lastName = lastName
|
|
|
|
def set_email(self, email):
|
|
self._email = email
|
|
|
|
def set_department(self, department):
|
|
self._department = department
|
|
|
|
# - Abstract methods
|
|
# - getFullName() - outputs the full name
|
|
# - addRequest() - pass
|
|
# - checkRequest() - pass
|
|
# - addUser() - outputs "User has been added"
|
|
|
|
def getFullName(self):
|
|
return f"{self._firstName } {self._lastName}"
|
|
|
|
def addRequest(self):
|
|
pass
|
|
|
|
def checkRequest(self):
|
|
pass
|
|
|
|
def addUser(self):
|
|
return "User has been added"
|
|
|
|
# - Custom methods
|
|
# - login() - outputs "<Email> has logged in"
|
|
# - logout() - outputs "<Email> has logged out"
|
|
|
|
def login(self):
|
|
return f"{self._email} has logged in"
|
|
|
|
def logout(self):
|
|
return f"{self._email} has logged out"
|
|
|
|
# 6. Create a **Request** class with the following properties and methods:
|
|
# - Properties (Define the properties as **protected**, and implement **getters and setters** for each.)
|
|
# - name
|
|
# - requester
|
|
# - dateRequested
|
|
# - status - "Open"
|
|
|
|
class Request():
|
|
def __init__(self, name, requester, dateRequested):
|
|
self._name = name
|
|
self._requester = requester
|
|
self._dateRequested = dateRequested
|
|
self._status = "Open"
|
|
|
|
# getters and setters
|
|
def get_name(self):
|
|
return self._name
|
|
|
|
def get_requester(self):
|
|
return self._requester
|
|
|
|
def get_dateRequested(self):
|
|
return self._dateRequested
|
|
|
|
def get_status(self):
|
|
return self._status
|
|
|
|
def set_name(self, name):
|
|
self._name = name
|
|
|
|
def set_requester(self, requester):
|
|
self._requester = requester
|
|
|
|
def set_dateRequested(self, dateRequested):
|
|
self._dateRequested = dateRequested
|
|
|
|
def set_status(self, status):
|
|
self._status = status
|
|
|
|
# - Custom Methods
|
|
# - updateRequest() - outputs “Request <name> has been updated”
|
|
# - closeRequest() - outputs “Request <name> has been closed”
|
|
# - cancelRequest() - outputs “Request <name> has been cancelled”
|
|
|
|
def updateRequest(self):
|
|
return f"Request {self._name} has been updated"
|
|
|
|
def closeRequest(self):
|
|
return f"Request {self._name} has been closed"
|
|
|
|
def cancelRequest(self):
|
|
return f"Request {self._name} has been cancelled"
|
|
|
|
# 7. Comment out the test cases before updating the local session Git repository.
|
|
# 8. Update your local session Git repository and push to Git with the commit message "Add activity code s05".
|
|
# 9. Add the repository link in Boodle for s05.
|
|
|
|
# Test cases:
|
|
|
|
employee1 = Employee("John", "Doe", "djohn@mail.com", "Marketing")
|
|
employee2 = Employee("Jane", "Smith", "sjane@mail.com", "Marketing")
|
|
employee3 = Employee("Robert", "Patterson", "probert@mail.com", "Sales")
|
|
employee4 = Employee("Brandon", "Smith", "sbrandon@mail.com", "Sales")
|
|
admin1 = Admin("Monika", "Justin", "jmonika@mail.com", "Marketing")
|
|
teamLead1 = TeamLead("Michael", "Specter", "smichael@mail.com", "Sales")
|
|
req1 = Request("New hire orientation", teamLead1, "27-Jul-2021")
|
|
req2 = Request("Laptop repair", employee1, "1-Jul-2021")
|
|
|
|
assert employee1.getFullName() == "John Doe", "Full name should be John Doe"
|
|
assert admin1.getFullName() == "Monika Justin", "Full name should be Monika Justin"
|
|
assert teamLead1.getFullName() == "Michael Specter", "Full name should be Michael Specter"
|
|
assert employee2.login() == "sjane@mail.com has logged in"
|
|
assert employee2.addRequest() == "Request has been added"
|
|
assert employee2.logout() == "sjane@mail.com has logged out"
|
|
|
|
teamLead1.addMember(employee3)
|
|
teamLead1.addMember(employee4)
|
|
for indiv_emp in teamLead1.get_members():
|
|
print(indiv_emp.getFullName())
|
|
|
|
assert admin1.addUser() == "User has been added"
|
|
|
|
req2.set_status("closed")
|
|
print(req2.closeRequest()) |