Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
3.6 kB
1
Indexable
Never

from typing import List


def salary_compute(base_salary: float, 
                   work_days: int, 
                   salary_factor: float)->float:
    return base_salary *1000 * work_days *salary_factor


salary_factor_mapping = {
    "A": [10, 12, 14, 20],
    "B": [10, 11, 13, 16],
    "C": [9, 10, 12, 14],
    "D": [8, 9, 11, 13]
} 

def working_years_mapping(years: int)->int:
    if years in range(1,4):
        return 0
    if years in range(4,9):
        return 1
    if years in range(9, 16):
        return 2
    if years >= 16:
        return 3

def salary_factor_compute(kind: str, years: int)->float:

    return salary_factor_mapping[kind][working_years_mapping(years)]
class EmployeeID:
    kind: str = "A"
    working_years : str = "10"
    group_id : str = "HC"    


class Employee:
    def __init__(self, 
                 employee_id: str,
                 employee_name: str,
                 base_salary: int = 0,
                 working_days: int =1,
                 ) -> None:
        self.employee_id = employee_id
        self.employee_name = employee_name
        self.base_salary = base_salary
        self.working_days = working_days
        self.employee_id_process(self.employee_id)
        self.update_salary()

    def employee_id_process(self, id: str):
        assert len(id) == 5
        self.ID = EmployeeID()
        self.ID.kind = id[:1]
        self.ID.working_years = int(id[1:3])
        self.ID.group_id = id[3:]
        

    def update_salary(self):
        self.salary = salary_compute(
            self.base_salary, 
            self.working_days, 
            salary_factor_compute(self.ID.kind, self.ID.working_years)
        )

    def get_info_str(self, group_mapper: dict)->str:
        return f"{self.employee_id} {self.employee_name} {group_mapper[self.ID.group_id]} {self.salary}"

class Group:
    def __init__(self,
                 group_id: str,
                 group_name: str,)->None:
        pass


class Program:
    def __init__(self) -> None: 
        self.groups  : List[Group] = []        
        self.employees : List[Employee] = []
        self.group_numbers = 0
        self.employee_numbers = 0
        self.groups_mapper = {}

    def input_processer(self):
        self.group_numbers = int(input())
        self.groups  : List[Group] = []
        for i in range(self.group_numbers):
            group_str = input()
            group_str_list = group_str.split(" ")
            group_id = group_str_list[0]
            group_name = " ".join(group_str_list[1:])
            self.groups.append(
                Group(
                    group_id=group_id,
                    group_name=group_name
                )
            )
            self.groups_mapper.update({group_id: group_name})
        self.employee_numbers = int(input())
        self.employees : List[Employee] = []
        for i in range(self.employee_numbers):
            employee_id : str = input()
            employee_name: str = input()
            base_salary: int =  int(input())
            working_days: int = int(input())
            self.employees.append(
                Employee(
                    employee_id,
                    employee_name,
                    base_salary,
                    working_days
                )
            )

    def output_processor(self):
        for employee in self.employees:
            employee_info : str = employee.get_info_str(group_mapper=self.groups_mapper)
            print(employee_info)
            print("\n")


if __name__=="__main__":
    program = Program()
    program.input_processer()
    program.output_processor()