Demo entry 6738541

main

   

Submitted by anonymous on May 04, 2018 at 10:53
Language: Python. Code size: 8.8 kB.

from Algorithms import *#Imports my algorithms from a seperate file named Algorithms

class Users:#This is the user class that both SalesAssistants and Management inherit from.



    def __init__(self,ID,password):
        #This initialises the variables below

        self.ID = ID

        self.__password = password



    def login(self, password):

        return self.__password == password

            

    def get_ID(self):

        return self.ID

            

    def set_password(self, new_password):

        self.__password = new_password

    

    def description(self):

        raise NotImplementedError



class Management(Users):



    def __init__(self,ID, password,department,availability):
        #This initialises the variables below

        Users.__init__(self,ID,password)#Inherits the Users class into Management class

        self.availability = availability

        self.department = department



    def get_department(self):
        #This gets the department entered from the user

        return self.department



    def get_availability(self):
        #Gets the availability entered from the user

        return self.availability



    def get_description(self):
        #Gets the description entered from the user

        return 'Management'





class SalesAssistants(Users):



    def __init__(self,ID,password,department,availability):
        #This initialises the variables below

        Users.__init__(self,ID,password) #Inherits the Users class into SalesAssistants class

        self.availability = availability

        self.department = department



    def get_department(self):
        #This gets the department entered from the user

        return self.department



    def get_availability(self):
        #Gets the availability entered from the user

        return self.availability



    def get_description(self):
        #Gets the description entered from the user

        return 'Sales Assistant'



class Staff():



    def __init__(self):
        #This initialises the variables below

        self.staff_list = []



    def get_no_users(self):
        #Gets the number of users in a list

        return self.no_users



    def linear_search_user(self, ID):
        #Searches for a paticular user in a list

        return linear_search(self.staff_list,ID)



    def binary_search_user(self,ID):
        #Searches for a paticular user in a list

        return binary_search(self.staff_list,ID)



    def bubble_sort_users(self):
        #Sorts the list of users

        self.staff_list = bubble_sort(self.staff_list)



    def merge_sort_users(self):
        #Sorts the list of users

        self.staff_list = merge_sort(self.staff_list)



    def delete_user(self,index):
        #Deletes a given user

        del self.staff_list[index]

        self.no_users -= 1 #Reduces the number of staff in the list by 1



    def add_management(self, ID, password, availability,department):
        #Adds management objects to the list

        self.staff_list.append(Management(ID,password,availability,department))



    def add_sales_assistant(self, ID, password, availability,department):
        #Adds sales assistant objects to the list

        self.staff_list.append(SalesAssistants(ID,password,availability,department))



   



    def get_staff(self,ID):
        #Gets the staff from the list

        for staff in self.staff_list:

            if staff.get_ID() == ID:

                return staff



    def get_sales_assistants(self):
        #Gets sales assistants from the list and adds them to a sales assistant list

        SalesAssistantList = []

        for staff in self.staff_list:

            if staff.get_description() == 'Sales Assistant':

                SalesAssistantList.append(staff)

        return SalesAssistantList



    def get_management(self):
        #Gets management from the list and adds them to a management list

        ManagementList = []

        for staff in self.staff_list:

            if staff.get_description() == 'Management':
               
                ManagementList.append(staff) #add manager to list

        return ManagementList



        

class Shift:



    def __init__(self,ShiftDate, management_object, salesassistant_object):
        #This initialises the variables below

        self.ShiftDate = ShiftDate

        self.StaffList = []

        self.add_sales_assistant(salesassistant_object) 

        self.add_management(management_object)



    def add_management(self,management_object):
        #Adds management objects to StaffList
        self.StaffList.append(management_object)



    def add_sales_assistant(self,salesassistant_object): # new parameter
        #Adds sales assistant objects to StaffList
        self.StaffList.append(salesassistant_object)



    def get_staff(self):
        #Gets the staff in StaffList
        result = []
        print(self.StaffList)
        for staff in self.StaffList:
            result.append(staff) #Add the object 
        return result

    

    def get_shift_date(self):
        #Adds the day of the shift

        return self.ShiftDate

    

class Rota:



    def __init__(self):
        #This initialises the variables below

        self.rota = []



    def add_shift(self,ShiftDate,management_object, salesassistant_object):
        #Creates a shift and adds management objects, sales assistant objects and the day

        self.rota.append(Shift(ShiftDate,management_object, salesassistant_object)) #missing 2 required positional arguments: 'management_object' and 'salesassistant_object'
 



    def get_shift(self,ShiftDate):
        #Gets the shift

        for shift in self.rota:

            if shift.get_shift_date() == ShiftDate:

                return shift

    

class Queue:



    #Constructor

    def __init__(self):
        #This initialises the variables below

        self.queue = list()

        self.maxSize = 5

        self.head = 0

        self.tail = 0



    #Adding elements

    def add_queue(self,data):

        #Checking if the queue is full

        if self.size() >= self.maxSize:

            return ("Queue Full")

        self.queue.append(data)

        self.tail += 1

        return True     



    #Deleting elements 

    def delete_queue(self):

        #Checking if the queue is empty

        if self.size() <= 0:

            self.resetQueue()

            return ("Queue Empty") 

        data = self.queue[self.head]

        self.head+=1

        return data

                

    #Calculate size

    def size(self):

        return self.tail - self.head

    

    #Reset queue

    def resetQueue(self):

        self.tail = 0

        self.head = 0

        self.queue = list()





if __name__=='__main__':





    staff = []



    Monday =Queue()

    Tuesday = Queue()

    Wednesday = Queue()

    Thursday = Queue()

    Friday = Queue()

    Saturday =Queue()

    Sunday = Queue()



    Availability = input("Enter you're available:  ")

    if Availability == 'Monday':

      ID = input('Enter you ID: ')

      print(Monday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)



    if Availability == 'Tuesday':

      ID = input('Enter you ID: ')

      print(Tuesday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)

      

    if Availability == 'Wednesday':

      ID = input('Enter you ID: ')

      print(Wednesday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)

      

    if Availability == 'Thursday':

      ID = input('Enter you ID: ')

      print(Thursday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)

      

    if Availability == 'Friday':

      ID = input('Enter you ID: ')

      print(Friday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)

      

    if Availability == 'Saturday':

      ID = input('Enter you ID: ')

      print(Saturday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)

      

    if Availability == 'Sunday':

      ID = input('Enter you ID: ')

      print(Sunday.add_queue(ID))

      print(staff)

      staff.append(ID)

      print(staff)





        



        

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).