美文网首页
day-13作业

day-13作业

作者: FansYuercero | 来源:发表于2018-08-01 17:36 被阅读0次

面向对象人力资源管理系统:

  • 能存多个员工信息
    (每个员工的信息有:姓名、年龄、工号、薪资、职位、部门)
  • 新员工入职(添加员工)
  • 员工离职(删除员工)
  • 查看某个员工的信息
  • 查询薪资最高的员工
  • 查询指定部门中所有员工的平均薪资
  • 求整个公司的员工的平均年龄
from random import randint
class Employees:
    def __init__(self,name,age,id,sex,salary,position,department):
        self.name = name
        self.age = age
        self.sex = sex
        self.id = id
        self.salary = salary
        self.position = position
        self.department = department
    def __str__(self):
        return str('name is %s,age is %d,id is %s,sex is %s,salary is %s,position is %s,department is%s'%(self.name,self.age,self.id,self.sex,self.salary,self.position,self.department))



class Company:
    def __init__(self,name='',employees=[]):
        self.company_name = name
        self.employees = employees
    def add_employees(self):
        name = input('employees\'name')
        age = input('employees\'age')
        sex = input('employees\'sex')
        salary = input('employees\'salary')
        position = input('employees\'position')
        department = input('employees\'department')
        id = 'RideoCos0001'+str(randint(1,100)).rjust(3,'0')
        emp = Employees(name,int(age),id,sex,float(salary),position,department)
        self.employees.append(emp)

    def check_employees(self):
        input_info = input('input the employees\'s name or id')
        for item in self.employees:
            if input_info == item.name or input_info == item.id:
                print(item)
    def check_all_employees(self):
        for item in self.employees:
            print(item)
    def del_employees(self):
        input_info = input('input the employees\'s name or id')
        for item in self.employees[:]:
            if input_info == item.name or input_info == item.id:
                self.employees.remove(item)
    def check_high(self):
        list1 = []
        for item in self.employees:
            list1.append(item.salary)
        print('the highest salary is%.2f'%max(list1))
    def check_department(self):
        department = input('input the department which you wonder checking')
        list2 = []
        for item in self.employees:
            if department == item.department:
                list2.append(item.salary)
        print('this %s avg salary is %.2f'%(department,(sum(list2)/len(list2))))
    def check_avg(self):
        list3 = []
        for item in self.employees:
            list3.append(item.salary)
        print('this company\'s avg salary is%.2f'%(sum(list3)/len(list3)))




while True:
    print('*'*50)
    clsone = Company('寰宇集团')
    print('1.添加员工\n2.查找员工\n3.删除员工\n4.查看所有员工\n5.查看最高薪资\n6.查部门平均工资\n7.查公司平均工资\nq.退出')
    choose = input('>>>')
    if choose=='1':
        while True:
            clsone.add_employees()
            print('1.继续添加\n2.返回上级')
            choose1 = input('>>>')
            if choose1 !='1'or choose1=='2':
                break
            continue

    elif  choose=='2':
        while  True:
            clsone.check_employees()
            print('1.继续查看\n2.返回上级')
            choose2 = input('>>>')
            if choose2 != '1' or choose2 == '2':
                break
            continue
    elif choose =='3':
        while True:
            clsone.del_employees()
            print('1.继续删除\n2.返回上级')
            choose3 = input('>>>')
            if choose3 != '1' or choose3 == '2':
                break
            continue
    elif choose=='4':
        while True:
            clsone.check_all_employees()
            print('1.返回上级')
            choose4 = input('>>>')
            if choose4==1:
                break
            break
    elif choose == '5':
        while True:
            clsone.check_high()
            print('1.返回上级')
            choose5 = input('>>>')
            if choose5 == 1:
                break
            break
    elif choose == '6':
        while True:
            clsone.check_department()
            print('1.继续查询\n2.返回上级')
            choose6 = input('>>>')
            if choose6 != '1' or choose6 == '2':
                break
            continue
    elif choose == '7':
        while True:
            clsone.check_avg()
            print('1.返回上级')
            choose7 = input('>>>')
            if choose7 == 1:
                break
            break


    else:
        break

相关文章

  • day-13作业

    面向对象人力资源管理系统: 能存多个员工信息(每个员工的信息有:姓名、年龄、工号、薪资、职位、部门) 新员工入职(...

  • day-13 作业

    1.声明⼀个电脑类: 属性:品牌、颜⾊、内存⼤小 方法:打游戏、写代码、看视频a.创建电脑类的对象,然后通过对象点...

  • 2018-09-09 day-13 作业

  • DAY-13

  • 日更45/100:重新理解“前途是光明的,道路是曲折的”。

    重新理解“前途是光明的,道路是曲折的”。 ——精听《刘润·商业洞察力30讲》&精读《系统之美》DAY-13 《刘润...

  • day-13总结

    1.编程思想编程思想:1.面向过程编码 - 逻辑、算法遇到问题,考虑直接把逻辑思维转换成代码,解决问题 2.函数式...

  • 得到专栏读后记:《刘润·5分钟商学院》

    【大螺丝】打卡 | 专栏读后记 《你的公司有“户口制度”吗?》 Day-13 此篇主要是想讨论企业管理者应该怎样去...

  • [Python] (Day-13) - 模块

    类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合。...

  • Dear John day-13

    John終於又見到了他日思夜想的Savaannah。在飛機上的時候John還在想他見到Savannah的時候會是什...

  • Day-13 逻辑函数IF,AND,OR

    一、分享一刻 任何收获都不是巧合,而是用日复一日的付出换来。不怕你每天迈的步子太小,只怕你停滞不前;不怕你每天做的...

网友评论

      本文标题:day-13作业

      本文链接:https://www.haomeiwen.com/subject/cgvrvftx.html