Pyhton Lab12.3

 avatar
unknown
python
2 years ago
3.5 kB
13
Indexable
class Name:
    
    def __init__(self, title="", fname="", lname=""):
        self.title = title
        self.fname = fname
        self.lname = lname

    def setName(self, t, f, l):
        self.title = t
        self.fname = f
        self.lname = l
    
    def getFullName(self):
        self.fullname = self.title + ". " + self.fname + self.lname
        return self.fullname

class Date:

    def __init__(self, d, m, y):
        self.d = d
        self.m = m
        self.y = y
    
    def setDate(self, d, m, y):
        if (d in range(1,32)) and (m in range(1,13)):
            self.d = d
            self.m = m
            self.y = y

    def getDate(self):
        return f"{self.d}/{self.m}/{self.y}"

    def getDateBC(self):
        return f"{self.d}/{self.m}/{self.y + 543}"

class Address:
    
    def __init__(self, hNo, st, dis, city, coun, post):
        self.hNo = hNo
        self.st = st
        self.dis = dis
        self.city = city 
        self.coun = coun
        self.post = post

    def setAddress(self, hNo, st, dis, city, coun, post):
        self.hNo = hNo
        self.st = st
        self.dis = dis
        self.city = city 
        self.coun = coun
        self.post = post

    def getAddress(self):
        return f"{self.hNo}, {self.st}, {self.dis}, {self.city}, {self.city}, {self.coun}, {self.post}"

class Person(Name, Date, Address):

    def __init__(self, title, fname, lname, d, m, y, hNo, st, dis, city, coun, post):
        super().__init__(title, fname, lname, d, m, y, hNo, st, dis, city, coun, post)
        self.name = self.getFullName()
        self.birthday = self.getDate()
        self.address = self.getAddress()

    def printInfo(self):
        print(f"{self.name}\n{self.birthday}\n{self.address}")

class Employee(Person):

    def __init__(self, title, fname, lname, d, m, y, hNo, st, dis, city, coun, post):
        super().__init__(title, fname, lname, d, m, y, hNo, st, dis, city, coun, post)
        self.startDate = self.getDate()
        self.department = None
    
    def printInfo(self):
        print(f"{self.name}\n{self.startDate}\n{self.department}")

class TempEmployee(Employee):
    
    def __init__(self, title, fname, lname, d, m, y, hNo, st, dis, city, coun, post):
        super().__init__(title, fname, lname, d, m, y, hNo, st, dis, city, coun, post)
        self.wage = 0

    def printInfo(self):
        print(f"{self.name}\n{self.wage}")

class PermEmployee(Employee):

    def __init__(self, title, fname, lname, d, m, y, hNo, st, dis, city, coun, post):
        super().__init__(title, fname, lname, d, m, y, hNo, st, dis, city, coun, post)
        self.salary = 0

    def printInfo(self):
        print(f"{self.name}\n{self.salary}")

class Department(Employee):

    def __init__(self, des, manager, startDate, department):
        super().__init__(startDate, department)
        self.des = des
        self.manager = manager
        self.eList = []

    def addEmployee(self, x):
        self.eList.append(x)
        self.department = self.des

    def delEmployee(self, x):
        for i in self.eList:
            if i.name == x:
                del i
        self.department = "null"

    def setManager(self, x):
        if (x in self.eList) and isinstance(x, PermEmployee):
            self.manager = x

    def printInfo(self):
        print(f"{self.des}\n{self.manager}\n{self.eList}")
Editor is loading...