def main(): lums = University("LUMS") eecs = Department(lums, "EECS"); civil = Department(lums, "CIVIL"); me = Department(lums, "MECHANICAL"); lums.Print();
def departments(): st.header('DEPARTMENTS') option_list = ['', 'Add department', 'Update department', 'Delete department', 'Show complete department record', 'Search department', 'Show doctors of a particular department'] option = st.sidebar.selectbox('Select function', option_list) d = Department() if (option == option_list[1] or option == option_list[2] or option == option_list[3]) and verify_edit_mode_password(): if option == option_list[1]: st.subheader('ADD DEPARTMENT') d.add_department() elif option == option_list[2]: st.subheader('UPDATE DEPARTMENT') d.update_department() elif option == option_list[3]: st.subheader('DELETE DEPARTMENT') try: d.delete_department() except sql.IntegrityError: # handles foreign key constraint failure issue (due to integrity error) st.error('This entry cannot be deleted as other records are using it.') elif option == option_list[4]: st.subheader('COMPLETE DEPARTMENT RECORD') d.show_all_departments() elif option == option_list[5]: st.subheader('SEARCH DEPARTMENT') d.search_department() elif option == option_list[6]: st.subheader('DOCTORS OF A PARTICULAR DEPARTMENT') d.list_dept_doctors()
def main(): manO = Manager("Ola", "Anton", 250, 3, 3) desP = Designer("Peta", "Petrov", 200, 2, 0.5, manO) desO = Designer("Ooo", "Eee", 250, 3, 0.8, manO) devI = Developer("Ivan", "Ivanov", 300, 3, manO) devR = Developer("Ryslan", "Ruslanov", 400, 5, manO) devD = Developer("Ddd", "Ddd", 500, 6, manO) desV = Designer("Vvv", "Vvv", 600, 10, 0.9, manO) manA = Manager("Aaa", "Aaa", 250, 3, 3) depart = Department() for i in range(len(Human.humans)): Human.humans[i].getEmployee() print('\n') #devI.getEmployee() #manO.getEmployee() #desO.getEmployee() #desP.getEmployee() depart.manList() depart.salary() manO.teamAdd(devI, desO, desP, devR, devD, desV, manA) manO.printSallary() devI.printSallary() desP.printSallary()
def setUp(self): self.managers = [ Manager("Bill", "Gates", 1000, 10), Manager("Mark", "Zuckerberg", 900, 3), Manager("Sergey", "Brin", 900, 1), Manager("Steve", "Jobs", 800, 8) ] self.depart = Department(self.managers) self.employees = [ Designer("tom", "taylor", 800, 10, self.managers[0], effect_coeff=0.5), Developer("dev1", "java", 500, 2, self.managers[0]), Developer("dev2", "js", 500, 6, self.managers[0]), Designer("armani", "jeans", 1200, 3, self.managers[1], effect_coeff=1), Designer("dolce", "gabbana", 800, 6, self.managers[1]), Developer("dev3", "basic", 500, 0.5, self.managers[1]), Developer("dev4", "python", 500, 6) ] self.employees_salary_expected = [730, 500, 1100] self.managers_salary_expected = [1870] self.wrong_list = ["vasya", "petya", "kolya", 15, True]
def test_ini(self): #тут був __init__ замість test_init emp_1 = Salaried_emp("Denis", "Shevchenka", "06.09.2001", "head", 120000) emp_2 = Hourly_emp("Viktor", "Stryiska", "24.04.2001", "analyst", 12, 180) self.employees = (emp_1, emp_2) self.location = Location(8, "BA") self.department = Department("BA", "Denis", self.location, self.employees)
def setUp(self) -> None: """Initialize setup object""" self.department = Department("Emergency") self.department1 = Department("Surgery") self.read_mock = Mock() self.department._write_to_file = self.read_mock self.doctor1 = Doctor("George", "Bush", "1982-2-28", "97334 Oak Bridge , Vancouver, Vancouver, BC", 2, False, 125, 190000) self.patient1 = Patient("Jose", "McDonald", "1970-12-12", "3432 Newtons, Richmond, BC", 1, False, 590) self.doctor2 = Doctor("Johnny", "Kenedy", "1984-1-30", "1444 Oakway, North Vancouver, Vancouver, BC", 1, False, 123, 150000) self.patient2 = Patient("Bill", "Stark", "1970-12-12", "1111 Columbia, New Westminster, BC", 2, False, 589, 10000) self.patient3 = Patient("Tony", "Stark", "1960-9-2", "1111 Columbia, New Westminster, BC", 12, False, 589)
def main(): managers = [ Manager("Bill", "Gates", 1000, 10), Manager("Mark", "Zuckerberg", 900, 3), Manager("Sergey", "Brin", 900, 1), Manager("Steve", "Jobs", 800, 8) ] employees = [ Designer("tom", "taylor", 800, 10, managers[0], effect_coeff=0.5), Developer("dev1", "java", 500, 2, managers[0]), Developer ("dev2", "js", 500, 6, managers[0]), Designer("armani", "jeans", 1200, 3, managers[1], effect_coeff=1), Designer("dolce", "gabbana", 800, 6, managers[1]), Developer ("dev3", "basic", 500, 0.5, managers[1]), Developer ("dev4", "python", 500, 6) ] depart = Department(managers) wrong_list = ["vasya","petya","kolya", 15, True] depart.give_salary() depart.add_team_members(managers[-1], employees[-1::]) # employees[-1].set_manager(managers[-1]) depart.give_salary() depart.add_team_members(managers[-2], employees[-1::]) #employees[-1].set_manager(managers[-2]) depart.give_salary() depart.add_team_members(managers[1], employees[-1::]) # employees[-1].set_manager() depart.give_salary() depart.add_team_members(managers[0], employees) depart.give_salary() depart.add_team_members(managers[-1], []) depart.give_salary() depart.add_team_members(managers[-1], wrong_list) depart.give_salary() wrong_list.extend(employees[-1::]) depart.add_team_members(managers[-1], wrong_list) depart.give_salary() depart.add_team_members(managers[-1], managers[:-1:]) depart.give_salary()
def __init__(self): self.sum_hours=sum_hours self.instructors_hours=instructors_hours self.instructors_names=instructor_names self.instructors_hours_empty=instructors_hours_empty self.cscourses =[] self.itcourses =[] self.iscourses =[] self.courses= [] self.departments1=[] self.instructors = [] self.instructors.append(ahmed) self.instructors.append(mohamed) self.instructors.append(ali) self.cscourses.append(selected) self.cscourses.append(operating_system) self.iscourses.append(ethics) self.iscourses.append(database2) self.itcourses.append(network) self.itcourses.append(electronics) self.courses.append(selected) self.courses.append(operating_system) self.courses.append(ethics) self.courses.append(database2) self.courses.append(network) self.courses.append(electronics) self.csdept = Department("cs", self.cscourses) self.isdept = Department("is", self.iscourses) self.itdept = Department("it", self.itcourses) self.departments1.append(self.csdept) self.departments1.append(self.isdept) self.departments1.append(self.itdept)
def test_all_in_one(self): loc_1 = Location(8, "BA") assert ("Room 8. Department: BA" == str(loc_1)) assert (8 == loc_1.get_room()) assert (loc_1.get_department == "BA") emp_1 = Salaried_emp("Denis", "Shevchenka", "06.09.2001", "head", 120000) emp_2 = Hourly_emp("Viktor", "Stryiska", "24.04.2001", "analyst", 12, 180) assert (isinstance(emp_1, Employee)) assert (isinstance(emp_2, Employee)) assert (emp_1.name == "Denis") assert ("Shevchenka" == emp_1.address) assert ("06.09.2001" == emp_1.birthday) assert ("head" == emp_1.position) assert (120000 == emp_1.salary) assert (12 == emp_2.worked_h) assert (180 == emp_2.salary_p_h) assert (( str(emp_1) == "Salaried_emp<Denis lives in Shevchenka street. Position: head. Birthday: 06.09.2001. Salary per month: $120000" )) assert (( str(emp_1) == "Hourly_emp<Viktor lives in Stryiska street. Position: analyst. Birthday: 24.04.2001. Salary per hour: $180. Worked hours per day: 12" )) # changes to 180 employee_list = (emp_1, emp_2) dep_1 = Department("BA", "Denis", loc_1, employee_list) # workers should be in tuple assert (isinstance(dep_1.workers, tuple)) # location must be instance of Location class assert (isinstance(dep_1.location, Location)) assert (dep_1.get_location() == "Room 8. Department: BA") assert (dep_1.sum_salary() == 60000) assert ( dep_1.get_inf_workers() == "Denis lives in Shevchenka street. Position: manager. Birthday: 06.09.2001. Salary per month: $30000\nHourly_emp<Viktor lives in Stryiska street. Position: analyst. Birthday: 24.04.2001. Salary per hour: $180. Worked hours per day: $1000" )
self.departments = departments def __str__(self): return f"Wecome to the Quarantine store! Have a nice shopping experience!" def print_departments(self): for id in self.departments: print(self.departments[id]) print() departments = { 23: Department(23, "Groceries", [ Product("Bananas", 0.60), Product("Avocados", 2), Product("Watermelons", 6) ]), 9: Department(9, "Books", [ Product("Game of Thrones", 10), Product("Fahrenheit 451", 15), Product("Working in Public", 25) ]), 13: Department(13, "Electronics", [ Product("Samsung 4K TV", 300), Product("iPhone SE", 400), Product("Pixel 4A", 100) ]), 7:
from testdata import TESTEMPLOYEES, TESTDEPARTMENTS from employee import Employee, Employees from department import Department, Departments employees = Employees() for empid, name, hiredate in TESTEMPLOYEES: employees.add_employee(Employee(empid, name, hiredate)) departments = Departments() for deptid, name, date_established in TESTDEPARTMENTS: departments.add_department(Department(deptid, name, date_established)) def main(): print("Employees:") for i in range(1, employees.headcount + 1): employee = employees.get_employee(i) print('Employee Id: {}; Name: {}; Date of Hire: {}'.format( employee.empid, employee.name, employee.hiredate)) print("Departments:") for i in range(*departments.departments_range): dept = departments.get_department(i) print('Department Id: {}; Name: {}; Date Established: {}'.format( dept.deptid, dept.name, dept.date_established)) print_summary(employees) print_summary(departments)
print("-----------------------------------") print("--------- Adam ERP --------") print("-----------------------------------") print('[ 사용자 메뉴 ]\n') print('1 - 인사 관리') print('2 - 프로젝트 관리') print('3 - 부서 관리') print('4 - 프로그램 종료') print("-----------------------------------") if __name__ == '__main__': # Project -----> Employee em = Employee() pj = Project(em) # Employee --> Department dp = Department() while True: print_menu() print("메뉴를 선택하세요 : ", end='') selected = input() if int(selected) == 1: em.executeJob(dp) elif int(selected) == 2: pj.execute_job() elif int(selected) == 3: dp.execute_job() elif int(selected) == 4: break
# -*- coding: UTF-8 -*- import random from faker import Faker from department import Department, DepartmentDAO def getLocation(): levels = [1, 2, 3, 4, 5] areas = ["A", "B", "C", "D", "E"] return f"{random.choice(levels)}楼{random.choice(areas)}区" fake = Faker("zh_CN") names = ("骨科门诊", "内科门诊", "妇科门诊", "针灸推拿科", "后滘门诊部", "急诊科", "骨伤一科(关节骨科)", "骨伤二科(创伤骨科)", "骨伤三科(脊柱骨科)", "骨伤四科(老年骨科)", "运动医学-关节镜科", " 妇二科(不孕不育科)", "重症医学科", "麻醉科", "医务科", "护理部", "药剂科", "医技功能室", "检验科", "放射科", "儿科门诊", "肛肠科门诊", "皮肤科门诊", "口腔科", "内科门诊", "内科住院部", "骨科门诊", "外科门诊", "眼耳鼻咽喉科", "妇科门诊", "急诊科", "妇科住院部", "针灸推拿科", "骨外科住院部", "山村门诊部", "脑病科", "康复科", "医教科", "护理部", "卫防科", "药剂科", "医技功能室", "检验科", "放射科") for i in range(len(names)): deptName = names[i] deptID = i + 1 location = getLocation() phone = fake.phone_number() dept = Department(deptID, deptName, location, phone) print(dept) DepartmentDAO.add(dept)
import json, os, re, smtplib, urllib, yaml from book import Book from department import Department, ChildrensLit, NotifyAboutEverything, SpanishInterestGroup ATOM_NAMESPACE = 'http://www.w3.org/2005/Atom' # The feed element ATOM = "{%s}" % ATOM_NAMESPACE # replaces the % and the s and replaces it follwed by anything after % config = yaml.safe_load(open('conf/evergreen.yml')) config.update(yaml.safe_load(open('conf/output.yml'))) departments = [] departments_config = yaml.safe_load(open('conf/departments.yml')) for d in departments_config['departments']: data = d.values()[0] departments.append(Department(d.keys()[0], ','.join(data['emails']), data['regex'])) # Add custom departments to the list departments.append(SpanishInterestGroup('*****@*****.**')) departments.append(NotifyAboutEverything('*****@*****.**')) departments.append(ChildrensLit('*****@*****.**')) if 'shelving_location' in config: if isinstance(config['shelving_location'], list): loc_string = '©Location='.join(str(location) for location in config['shelving_location']) else: loc_string = str(config['shelving_location']) feed_url = 'http://' + config['opac_host'] + '/opac/extras/browse/atom-full/item-age/' + config['org_unit'] + '/1/' + str(config['num_items_to_fetch']) + '?status=0&status=1&status=6&status=7©Location=' + loc_string # the URL that will return all the data we need else: feed_url = 'http://' + config['opac_host'] + '/opac/extras/browse/atom-full/item-age/' + config['org_unit'] + '/1/' + str(config['num_items_to_fetch']) + '?status=0&status=1&status=6&status=7'
#!/bin/python from employee import Employee from department import Department em1 = Employee("Anthony", "*****@*****.**") em2 = Employee("Carlos", "*****@*****.**") em3 = Employee("Matt", "*****@*****.**") dep = Department("001", "Administration") dep.addEmployee(em1) dep.addEmployee(em2) dep.addEmployee(em3) print dep.code, dep.name print "----------------------" for emp in dep.employee: print emp.name, emp.email, "\n\r"
elif work == "3": type_ = input("Enter the type of the Employee") empid = input("Enter the empid of the Employee") e.update_employee_type(type_, empid) else: print("Wrong Choice") else: print("You have Entered Wrong Password") elif key == "2": password = input("Enter the password for Updating Database of Department") if password == "dept123": d = Department() name = input("Enter name of the department") project = input("Enter the name of the project") deptid = input("Enter the Department ID") d.add_department(name, project, deptid) else: print("You have Entered Wrong Password") elif key == "3": password = input("Enter the password for Updating Database of coordinator") if password == "cod123": c = Coordinator() name = input("Enter Name of the Coordinator") cid = input("Enter your Coordinator Id")
# user will pass in either 0 or 1 command-line arguments to the program num_args = len(sys.argv) # if they pass in 0, we'll default their money to 100 if num_args == 1: user = User(100) # if they pass in 1 argument (a number), set their money to that amount elif num_args == 2: user = User(int(sys.argv[1])) else: print("Usage: store.py [money]") sys.exit(1) departments = { 23: Department(23, "Groceries", [Product("Bananas", 1), Product("Avocados", 2), Product("Watermelons", 4)]), 9: Department(9, "Books", [Product("Game of Thrones", 10), Product("Working in Public", 25), Product("Twilight", 10)]), 13: Department(13, "Electronics", [Product("Samsung 4K TV", 300), Product("iPhone SE", 400), Product("Pixel 4A", 350)]), 7: Department(7, "Clothes", [Product("Graphic T's", 20), Product("Kanye Sweater", 700), Product("Sketchers High Tops", 50)]), 15: Department(15, "Toys", [Product("Lightsaber", 200), Product("Nerf Guns", 200), Product("Settlers of Catan", 40), Product("Nintendo Lego Set", 150)]) } store = Store("Quarantine Store", departments) # print the store's welcome message print(store) # print user's status print(user, '\n') while True:
def ensure_department_existance(department_id): if not len( graph.data( "match (d:Department) where space_ship.get_hex_ident(d.ident) = '%s' return d.ident as ident" % department_id)) > 0: Department(ident=department_id).save()
def setUp(self): self.department = Department('produce')
from flask import Flask, jsonify, request, make_response from department import Department from patient import Patient from doctor import Doctor app = Flask(__name__) department = Department("Surgery") @app.route("/department/<person_type>", methods=["POST"]) def add_person(person_type): data = request.json if not data: return make_response("No JSON. Check headers and JSON format.", 400) try: if person_type == 'Patient': patient = Patient(data["first_name"], data["last_name"], data["date_of_birth"], data["address"], data["id"], data["is_released"], data["room_num"], data["bill"]) department.add_person(patient) elif person_type == 'Doctor': doctor = Doctor(data["first_name"], data["last_name"], data["date_of_birth"], data["address"], data["id"], data["is_released"], data["office_num"], data["income"]) department.add_person(doctor) else: return make_response("Type not found", 400)
#coding: utf-8 ################################## # Работа с классами # ################################## from person import Person from department import Department from manager import Manager Bob = Person(age=56, job="Tester") Bob.setName("Bob Oden") Bob.setPay(1000) Bob.giveRaise(100) John = Person("John Smith", "Programmer", 1e6, 17) Tom = Manager("Tom mi", 100, 20) Tom.giveRaise(8, 8) #Bob.newdata = "something" не рекомендуется присоединять аттрибуты за пределами класса development = Department(Bob, John) development.addMember(Tom) development.giveRaises(10) development.showAll()
from store import Store num_args = len(sys.argv) if num_args == 1: user = User(100) elif num_args == 2: user = User(int(sys.argv[1])) else: print("Usage: store.py [money]") sys.exit(1) departments = { 23: Department(23, "Groceries", [ Product("Bananas", 0.60), Product("Avos", 2.60), Product("Watermelon", 1.60) ]), 9: Department(9, "Books", [ Product("Game of Thrones", 10.60), Product("Working in Public", 12.60), Product("Watermelon Chronicles", 1.60) ]), 13: Department(13, "Electronics", [ Product("Samsung 4k TV", 300.60), Product("Iphone SE", 2000.60), Product("Pixel 4a", 1000.60) ]), 7:
def test_invalid_constructor(self): """Test an object with invalid parameters""" with self.assertRaises(TypeError): department_1 = Department(1)
def add_department(): name = input('Department Name: ') code = input('Department Code: ') return Department(name, code)
from employee import Employee from task import Task from boss import Boss from department import Department d = [] e = [] d.append(Department('Дизайн')) d.append(Department('Фронтэнд')) d.append(Department('Бэкэнд')) e.append(Boss('Марк')) e.append(Employee('Иван')) e.append(Employee('Алексей')) e.append(Employee('Сергей')) e.append(Boss('Денис')) e.append(Employee('Ярослав')) e.append(Employee('Кирилл')) e.append(Employee('Леонтий')) e.append(Boss('Данил')) e.append(Employee('Андрей')) e.append(Employee('Никита')) e.append(Employee('Владимир')) for i in range(12): if i < 4: e[i].assigndepartment(d[0]) d[0].addemployee(e[i]) if i >= 4 and i < 8: e[i].assigndepartment(d[1]) d[1].addemployee(e[i]) if i >= 8: e[i].assigndepartment(d[2]) d[2].addemployee(e[i])
TESTEMPLOYEES = ((1, 'Douglas Adams', datetime(1942, 7, 6)), (2, 'Sherlock Holmes', datetime(1887, 3, 15)), (3, 'Albert Einstein', datetime(1915, 11, 25)), (4, 'Sir John A Macdonald', datetime(1867, 8, 1)), (5, 'Theodore Roosevelt', datetime(1901, 9, 14))) TESTDEPARTMENTS = ((101, 'Sci-Fi Comedy', datetime(2010, 10, 1)), (102, 'Mystery', datetime(2012, 2, 13)), (103, 'Physics', datetime(2014, 5, 14)), (104, 'Politics', datetime(2016, 7, 28)), (201, 'POTUS', datetime(1776, 7, 4))) def populate_employees(employees_class): employees = employees_class() for number, name, date in TESTEMPLOYEES: employees.add_employee(Employee(number, name, date)) return employees employees1 = populate_employees(Employees1) employees2 = populate_employees(Employees2) employees3 = populate_employees(Employees3) departments = Departments() for number, name, date in TESTDEPARTMENTS: departments.add_department(Department(number, name, date))
def create_department(self, name): department = Department(name) self.database.insert_department(department) self.departments[department.id] = department return department
from department import Department from department_collection import Departments TESTEMPLOYEES = ( (1, 'Douglas Adams', datetime(1942, 7, 6)), (2, 'Sherlock Holmes', datetime(1887, 3, 15)), (3, 'Albert Einstein', datetime(1915, 11, 25)), (4, 'Sir John A Macdonald', datetime(1867, 8, 1)), (5, 'Theodore Roosevelt', datetime(1901, 9, 14)) ) employees = Employees() for empid, name, hiredate in TESTEMPLOYEES: employees.add_employee( Employee(empid, name, hiredate) ) TESTDEPARTMENTS = ( (101, 'Sci-Fi Commedy', datetime(2010, 10, 1)), (102, 'Mystery', datetime(2012, 2, 13)), (103, 'Physics', datetime(2014, 5, 14)), (104, 'Politics', datetime(2016, 7, 28)), (201, 'POTUS', datetime(1776, 7, 4)) ) departments = Departments() for deptid, name, date_established in TESTDEPARTMENTS: departments.add_department( Department(deptid, name, date_established) )
def load_departments(self): department_rows = self.database.get_departments() for department_row in department_rows: department = Department(department_row[1]) department.id = department_row[0] self.departments[department.id] = department