def main(): s1 = UG("Andrew Fu", 2020) s2 = UG("Rachel Song", 2020) s3 = UG("Alvie Stoddard", 2021) s4 = Grad("Matt Damon") s5 = UG("Mark Zuckerberg", 2019) p1 = Professor("Zhi Li", 'MIS 3640') p2 = Professor("Shankar", 'MIS 3690') p3 = BabsonPerson("Steve Gordon") q1 = Person("Bill Gates") q2 = Person("Beyonce") student_list = [s1, s2, s3, s5, s4] babson_list = student_list + [p1, p2, p3] all_list = babson_list + [q1, q2] # for everyone in student_list: # print(everyone) # for everyone in babson_list: # print(everyone) # print(everyone.speak("Happy holidays!")) for everyone in all_list: print(everyone)
def setProfessor(self, professorElement): professor = Professor(professorElement["first_name"], \ professorElement["last_name"], \ professorElement["id"]) self.professors.addProfessor(professor) return professor.getId()
def read_professors_from_file(classes_dict): all_teachers = [] fileInput = input( "Enter the name of the file you want to read the professors info from:" ) path = fileInput + ".csv" if os.path.isfile(path): file = open(path) reader = csv.reader(file) for line in reader: first = str(line[0]) last = str(line[1]) email = str(line[2]) wage = int(line[3]) department = str(line[4]) classes = str(line[5]).split(sep="-") professor = Professor(first, last, email, wage, department) all_teachers.append(professor) for group2 in classes: for title1, group1 in classes_dict.items(): if group2 == title1: professor.add_class(group1) else: pass else: print('No such file!') return all_teachers
def AttemptSignIn(self, username: str, password: str) -> str: if (username == "aa" and password == "aa"): courses = [] try: courses = self.course_manager.getCourses(0) except: pass userInfo = self.Manager.getUserInfo(0) if (len(userInfo[0][3]) != 0): user = Professor(0, courses, userInfo[0][1], userInfo[0][2], userInfo[0][0], userInfo[0][3]) else: user = Professor(0, courses, userInfo[0][1], userInfo[0][2], userInfo[0][0], []) main_window = MainWidget(user) return "success" if (username == "" or password == ""): return ("Error empty field(s)") else: model_result, entity, userID = self.Manager.CheckForUserPass( username, password) if (model_result == 1): courses = [] try: if (entity == "professor"): courses = self.course_manager.getCourses(userID) elif (entity == "student"): courses = self.course_manager.getCoursesStudent(userID) except: return ("Database down, use aa") userInfo = self.Manager.getUserInfo(userID) if ((userInfo[0][3]) != None): if (entity == 'student'): user = Student(userID, courses, userInfo[0][1], userInfo[0][2], userInfo[0][0], userInfo[0][3]) elif (entity == 'professor'): user = Professor(userID, courses, userInfo[0][1], userInfo[0][2], userInfo[0][0], userInfo[0][3]) else: if (entity == 'student'): user = Student(userID, courses, userInfo[0][1], userInfo[0][2], userInfo[0][0], []) elif (entity == 'professor'): user = Professor(userID, courses, userInfo[0][1], userInfo[0][2], userInfo[0][0], []) main_window = MainWidget(user) return "success" else: return ("Username or Password Incorrect")
def generateProfs(self): profs = Coordinator.profDb for prof in profs: name = prof.name p = Professor(name) for courseCode in prof.courses.split(","): course = self.getCourse(courseCode) p.addCourse(course) self.professors.append(p)
def setUp(self): self.public = True self.private = False self.L1 = Student("1", "L1", self.private) self.M11 = Student(11, "M11", self.private) self.T1 = Team( "Team1", 1, self.public, self.L1 ) self.Prof = Professor("golds") self.C1 = Course(10000, "CSCI-4440", 1, 75) self.C2 = Course(10001, "CSCI-4460", 1, 75)
def __init__(self): self.Matricula = Matricula() self.Professor = Professor() self.titulo = '' self.descricao = '' self.valor = '' self.sala = ''
def adminPage(): if request.method == 'POST': profEmail = request.form.get('professorEmail', None) approveProfessor(profEmail) if 'username' not in request.cookies or checkAdmin(request) == False: return render_template('signin.html', loginError="Going to unauthorized page") approvedProfList = [] unapprovedProfList = [] approvedProfs = get_approved_professors() unapprovedProfs = get_unapproved_professors() for approved in approvedProfs: approvedProfList.append((Professor(approved[3], approved[0]), getProfStatsForAdmin(approved[0]))) for unapproved in unapprovedProfs: unapprovedProfList.append(Professor(unapproved[3], unapproved[0])) return render_template('adminpage.html', approved=approvedProfList, unapproved=unapprovedProfList)
def main(): # Stworz nową bazę db = CollegeDb() # Dodaj Profesorow db.AddPerson(Professor("Andrzej", "Kowalski", "Prof.")) db.AddPerson(Professor("Monika", "Radzka", "Dr.")) # Dodaj studentów db.AddPerson(Student("Jan", "Rybak", uuid.uuid4())) db.AddPerson(Student("Krzysztof", "Dobrzyński", uuid.uuid4())) db.AddPerson(Student("Maria", "Łudzka", uuid.uuid4())) # Policz ile osób zostało zarejestrowanych print("Registered Persons = " + str(len(db.People))) input("Press key to close...")
def getTeachers(self): self.conn.execute_query('SELECT * FROM EmployeesAll') professors = {} for row in self.conn: professor = Professor(row['Id'], row['Title']) professors[row['Id']] = professor # print 'Professors count: ', len(professors) self._professors = professors return professors
from Disciplina import Disciplina from Professor import Professor D = Disciplina() listadisp = [] ListaDispP1 = [] ListaCargaP1 = [] ListaDispP2 = [] ListaCargaP2 = [] Prof = Professor() Prof.setApelido("GUGU") Prof.getApelido() D.altera_Nome("LP") D.altera_Carga(80) listadisp.append(D.getNome()) listadisp.append(D.getCarga()) Prof.adiciona_disciplina(ListaDispP1, ListaCargaP1, D.getNome(), D.getCarga()) D.altera_Nome("SQL") D.altera_Carga(80) listadisp.append(D.getNome()) listadisp.append(D.getCarga()) Prof.adiciona_disciplina(ListaDispP1, ListaCargaP1, D.getNome(), D.getCarga()) Prof.setApelido("Yuri") Prof.getApelido() D.altera_Nome("DevOPs") D.altera_Carga(80) listadisp.append(D.getNome()) listadisp.append(D.getCarga()) Prof.adiciona_disciplina(ListaDispP2, ListaCargaP2, D.getNome(), D.getCarga())
class ProfessorTest(unittest.TestCase): # the testing framework will automatically call for every single test we run # in our case, it can also serve as constructor test def setUp(self): self.public = True self.private = False self.L1 = Student("1", "L1", self.private) self.M11 = Student(11, "M11", self.private) self.T1 = Team( "Team1", 1, self.public, self.L1 ) self.Prof = Professor("golds") self.C1 = Course(10000, "CSCI-4440", 1, 75) self.C2 = Course(10001, "CSCI-4460", 1, 75) # test all getters def test_gets(self): self.assertEqual(self.Prof.getID(), "golds") self.assertEqual(len( self.Prof.getCourses() ), 0) # test all setters def test_sets(self): self.Prof.setID("silvers") self.assertEqual(self.Prof.getID(), "silvers") def test_addAndRemoveCourses(self): # add two courses self.assertTrue( self.Prof.addCourse(self.C1) ) self.assertTrue( self.Prof.addCourse(self.C2) ) self.assertEqual( len( self.Prof.getCourses() ), 2 ) self.assertEqual( (self.Prof.getCourses())[0].getCRN(), 10000 ) self.assertEqual( (self.Prof.getCourses())[1].getCRN(), 10001 ) # invalid add self.assertFalse( self.Prof.addCourse(self.C1) ) # remove one course self.assertTrue( self.Prof.removeCourse(self.C1) ) self.assertEqual( len( self.Prof.getCourses() ), 1 ) self.assertEqual( (self.Prof.getCourses())[0].getCRN(), 10001 ) # remove a non-existing course should fail self.assertFalse( self.Prof.removeCourse(self.C1) ) # remove another course self.assertTrue( self.Prof.removeCourse(self.C2) ) self.assertEqual( len( self.Prof.getCourses() ), 0 ) def test_addAndDeleteStudentTags(self): # valid adds self.assertTrue( self.Prof.addStudentTag(self.L1, "EDT") ) self.assertTrue( self.Prof.addStudentTag(self.L1, "Tuesday") ) self.assertEqual( len( self.L1.getTags() ), 2 ) # invalid adds, duplicates self.assertFalse( self.Prof.addStudentTag(self.L1, "EDT") ) self.assertEqual( len( self.L1.getTags() ), 2 ) self.assertEqual( (self.L1.getTags())[0], "EDT" ) self.assertEqual( (self.L1.getTags())[1], "Tuesday" ) # invalid deletes self.assertFalse( self.Prof.deleteStudentTag(self.L1, "PDT") ) self.assertEqual( len( self.L1.getTags() ), 2 ) # valid deletes self.assertTrue( self.Prof.deleteStudentTag(self.L1, "EDT") ) self.assertEqual( len( self.L1.getTags() ), 1 ) self.assertEqual( (self.L1.getTags())[0], "Tuesday" ) self.assertTrue( self.Prof.deleteStudentTag(self.L1, "Tuesday") ) self.assertEqual( len( self.L1.getTags() ), 0 ) def test_addAndDeleteTeamTags(self): # valid adds self.assertTrue( self.Prof.addTeamTag(self.T1, "EDT") ) self.assertTrue( self.Prof.addTeamTag(self.T1, "Tuesday") ) self.assertEqual( len( self.T1.getTags() ), 2 ) # invalid adds, duplicates self.assertFalse( self.Prof.addTeamTag(self.T1, "EDT") ) self.assertEqual( len( self.T1.getTags() ), 2 ) self.assertEqual( (self.T1.getTags())[0], "EDT" ) self.assertEqual( (self.T1.getTags())[1], "Tuesday" ) # invalid deletes self.assertFalse( self.Prof.deleteTeamTag(self.T1, "PDT") ) self.assertEqual( len( self.T1.getTags() ), 2 ) # valid deletes self.assertTrue( self.Prof.deleteTeamTag(self.T1, "EDT") ) self.assertEqual( len( self.T1.getTags() ), 1 ) self.assertEqual( (self.T1.getTags())[0], "Tuesday" ) self.assertTrue( self.Prof.deleteTeamTag(self.T1, "Tuesday") ) self.assertEqual( len( self.T1.getTags() ), 0 ) def test_addAndRemoveStudents(self): # valid adds self.assertTrue( self.Prof.addStudentToTeam(self.T1, self.M11) ) self.assertEqual( len( self.M11.getTeams() ), 1 ) self.assertEqual( len( self.T1.getMembers() ), 2 ) # invalid adds, duplicates self.assertFalse( self.Prof.addStudentToTeam(self.T1, self.M11) ) self.assertEqual( len( self.M11.getTeams() ), 1 ) self.assertEqual( len( self.T1.getMembers() ), 2 ) # valid removes self.assertTrue( self.Prof.removeStudentFromTeam(self.T1, self.M11) ) self.assertEqual( len( self.M11.getTeams() ), 0 ) self.assertEqual( len( self.T1.getMembers() ), 1 ) # invalid remove self.assertFalse( self.Prof.removeStudentFromTeam(self.T1, self.M11) ) self.assertEqual( len( self.M11.getTeams() ), 0 ) self.assertEqual( len( self.T1.getMembers() ), 1 ) def test_addAndRemoveAssignments(self): # valid adds # addAssignment(course, title, min, max, deadline) self.assertTrue( self.Prof.addAssignment(self.C1, "A1", 1, 4, 120220201159) ) self.assertEqual( len( self.C1.getAssignments() ), 1 ) # invalid adds, duplicates self.assertFalse( self.Prof.addAssignment(self.C1, "A1", 1, 4, 120220201159) ) self.assertEqual( len( self.C1.getAssignments() ), 1 ) A1 = (self.C1.getAssignments())[0] # invalid edit # editAssignment(self, assignment, title, min, max, deadline) self.assertFalse( self.Prof.editAssignment(None, "newA1", None, None, None) ) # valid edits self.assertTrue( self.Prof.editAssignment(A1, "newA1", None, None, None) ) self.assertEqual( A1.getTitle(), "newA1") # valid deletes self.assertTrue( self.Prof.deleteAssignment(self.C1, A1) ) self.assertEqual( len( self.C1.getAssignments() ), 0 )
("KPLP", ["TTP-41", "TTP-42"], "Tkachenko", ["Tkachenko"]), ("Business-analytics Systems", ["TTP-41", "TTP-42"], "Panchenko", ["Panchenko"]), ("Image Recognition", ["MI-4"], "Ryabokon", None), ("Refactoring Problems", ["MI-4"], None, ["Kuliabko"]), ("Quantum Computations Theory", ["MI-4"], "Riabokon", None), ("OS w/ Time Destribution", ["TK-4"], None, ["Koval"]), ("Machine Learning", ["TK-4"], "Trohymchuk", None), ("Neural Networks", ["TK-4"], "Pashko", None), ("PLKI", ["TK-4"], "Crack", None) ] # [(name, capacity, is_prac)] Group.groups = [Group(name, cap) for name, cap in groups] Professor.professors = [Professor(name) for name in professors] # [(name, capacity, is_prac)] Room.rooms = [Room(name, cap, lab) for name, cap, lab in rooms] # [(name, [groups], lecturer, [practical teacher(s)])] Course.courses = [ Course(name, groups, lect, prac) for name, groups, lect, prac in courses ] # [(start, end, day)] Timeslot.timeslots = [ Timeslot(time[0], time[1], day) for time, day in list(itertools.product(timeslots, days)) ]
def setUp(self): self.obj = Professor("William", "Adams", "*****@*****.**", 65000, "Computer Science") self.class_obj = Group("Cos101", 3)
from tkinter import * from Aluno import Aluno from Professor import Professor from Disciplina import Disciplina disciplina = Disciplina() professor = Professor() aluno = Aluno() def home_menu(): janela_principal = Tk() lb1 = Label(janela_principal, text="--- MENU ---") lb2 = Label(janela_principal, text="==============================================") lb3 = Label(janela_principal, text="--- Qual menu você deseja acessar? ---") lb4 = Label(janela_principal, text="==============================================") bt1 = Button(janela_principal, width=20, text="Alunos", command=alunos_menu) bt2 = Button(janela_principal, width=20, text="Professores", command=professores_menu) bt3 = Button(janela_principal, width=20,
POPULATION = 15 # here we specify the amount of population members which are supposed to be best N_BEST = int(POPULATION * 0.3) MUTATION_LEVEL = 10 Group.groups = [ Group("TTP-41", 25), Group("TTP-42", 20), Group("MI-4", 23), Group("TK-4", 12), Group("TTP-32", 24), Group("K-26", 24) ] Professor.professors = [ Professor("Taranukha"), Professor("Bugayov"), Professor("Fedorus"), Professor("Hlybovets"), Professor("Radyvonenko"), Professor("Ryabokon"), Professor("Kulyabko"), Professor("Zavadsky"), Professor("Tereschchenko"), Professor("Tymashoff"), Professor("Vergunova"), Professor("Panchenko"), Professor("Pashko"), Professor("Fedorova"), ]
value = input() aux = None if value == '1': print('\n\n\n\nINCLUIR - \n1 - Aluno \n2 - Professor \n3 - Coordenador \n4 - Disciplina \n5 - DisciplinaOfertada \n6 - Matricula (Digite e pressione ENTER)') print('Digite os dados e pressione ENTER:') value2 = input() if value2 == '1': ent = Aluno() ent.id = input('ID:') ent.nome = input('NOME:') ent.validate() DB.insert(ent) print('Aluno incluído com sucesso!') elif value2 == '2': ent = Professor() ent.id = input('ID:') ent.nome = input('NOME:') ent.validate() DB.insert(ent) print('Professor incluído com sucesso!') elif value2 == '3': ent = Coordenador() ent.id = input('ID:') ent.nome = input('NOME:') ent.validate() DB.insert(ent) print('Coordenador incluído com sucesso!') elif value2 == '4': ent = Disciplina() ent.id = input('ID:')
def primary_driver_logic(map_file_name): t1 = time() t0 = time() print("Creating Terrain Map") terrain_map = TerrainMap(map_file_name) # print(terrain_map) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() print("Creating Score Map") score_map = ScoreMap(terrain_map) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() print("Creating Prof") prof = Professor(terrain_map) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() if PRINT_ADVANCED_STATEMENTS: print("====STARTING PLACE====") print(prof) # possible_states = terrain_map.get_all_traversable_states() print("Generating Initial possible_states") possible_states = prof.get_all_possible_states() if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() if PRINT_ADVANCED_STATEMENTS: print("Starting Amount of possible_states: ", len(possible_states)) i = 0 print_once = False print("===Starting Primary Loop===") while prof.state.point.y < terrain_map.height - 1: current_surroundings = prof.get_surroundings() next_possible_states = [] if PRINT_ADVANCED_TIMING: t1 = time() if PRINT_LOOP_STATEMENTS: print("Narrowing States") for possible_state in possible_states: if prof.is_possible_state(possible_state, current_surroundings): next_possible_states.append(possible_state) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) possible_states = next_possible_states if len(possible_states) > 1: if FILE_OUT: FileOut.to_png(terrain_map=terrain_map, possible_states=possible_states, professor=prof, file_name="steps/step" + str(i)) i += 1 if PRINT_ADVANCED_STATEMENTS: print("Num possible states: ", len(possible_states)) # Now possible states have been trimmed down if len(possible_states) <= 1 and not print_once: print("+++++FOUND PROFESSOR+++++\nNow routing him home") if PRINT_ADVANCED_STATEMENTS: print('Current Score:', score_map.get_tile(prof.state.point).score) print_once = True if PRINT_ADVANCED_STATEMENTS: print(prof) print("isTraversible() ", terrain_map.get_tile(prof.state.point).is_traversable()) if PRINT_LOOP_STATEMENTS: print("Getting Smart Move") if PRINT_ADVANCED_TIMING: t1 = time() move = get_smart_move(score_map, possible_states) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() if PRINT_LOOP_STATEMENTS: print("Got Smart Move") # move = generate_random_valid_move(prof) if PRINT_ADVANCED_STATEMENTS: print(move) prof.move(move) if PRINT_LOOP_STATEMENTS: print("Moving All possible_states") for possible_state in possible_states: possible_state.move(move) if FILE_OUT: FileOut.to_png(terrain_map=terrain_map, possible_states=possible_states, professor=prof, file_name="steps/step" + str(i)) i += 1 if FILE_OUT and i > terrain_map.height * 1.25: print("NOT DONE YET BUT SAVING ISAAC'S SSD") break print("\n====RESTING PLACE===") print(prof) print("Professor has been routed successfully!") t2 = time() print('total time take: {} seconds'.format(t2 - t0)) return t2 - t0
def primary_driver_logic(map_file_name): t1 = time() t0 = time() print("Creating Terrain Map") terrain_map = TerrainMap(map_file_name) # print(terrain_map) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() print("Creating Score Map") score_map = ScoreMap(terrain_map) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() print("Creating Prof") prof = Professor(terrain_map) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() if PRINT_ADVANCED_STATEMENTS: print("====STARTING PLACE====") print(prof) # possible_states = terrain_map.get_all_traversable_states() print("Generating Initial possible_states") possible_states = prof.get_all_possible_states() if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() if PRINT_ADVANCED_STATEMENTS: print("Starting Amount of possible_states: ", len(possible_states)) i = 0 print_once = False print("===Starting Primary Loop===") while prof.state.point.y < terrain_map.height - 1: current_surroundings = prof.get_surroundings() next_possible_states = [] if PRINT_ADVANCED_TIMING: t1 = time() if PRINT_LOOP_STATEMENTS: print("Narrowing States") for possible_state in possible_states: if prof.is_possible_state(possible_state, current_surroundings): next_possible_states.append(possible_state) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) possible_states = next_possible_states if len(possible_states) > 1: if FILE_OUT: FileOut.to_png(terrain_map=terrain_map, possible_states=possible_states, professor=prof, file_name="steps/step" + str(i)) i += 1 if PRINT_ADVANCED_STATEMENTS: print("Num possible states: ", len(possible_states)) # Now possible states have been trimmed down if len(possible_states) <= 1 and not print_once: print("+++++FOUND PROFESSOR+++++\nNow routing him home") if PRINT_ADVANCED_STATEMENTS: print('Current Score:', score_map.get_tile(prof.state.point).score) print_once = True if PRINT_ADVANCED_STATEMENTS: print(prof) print("isTraversible() ", terrain_map.get_tile(prof.state.point).is_traversable()) if PRINT_LOOP_STATEMENTS: print("Getting Smart Move") if PRINT_ADVANCED_TIMING: t1 = time() move = get_smart_move(score_map, possible_states) if PRINT_ADVANCED_TIMING: print('time take: {} seconds'.format(time() - t1)) t1 = time() if PRINT_LOOP_STATEMENTS: print("Got Smart Move") # move = generate_random_valid_move(prof) if PRINT_ADVANCED_STATEMENTS: print(move) prof.move(move) if PRINT_LOOP_STATEMENTS: print("Moving All possible_states") for possible_state in possible_states: possible_state.move(move) if FILE_OUT: FileOut.to_png(terrain_map=terrain_map, possible_states=possible_states, professor=prof, file_name="steps/step" + str(i)) i += 1 if FILE_OUT and i > terrain_map.height * 1.25: print("NOT DONE YET BUT SAVING ISAAC'S SSD") break print("\n====RESTING PLACE===") print(prof) print("Professor has been routed successfully!") t2 = time() print('total time take: {} seconds'.format(t2 - t0)) return t2 - t0
if __name__ == "__main__": main() ############################################################################## ############################################################################## ################################ TESTING ################################ ############################################################################## ############################################################################## chau = Professor("Duen Chao", 3.97, {"CX4242":3.97},1.00,1) foley = Professor("Robert Foley",3.33, {"ISYE2027":2.89},3.8,36) CX4242 = Course("CX",4242,3,3.79) ISYE2027 = Course("ISYE",2027,3,2.86) s12345 = Section(12345,CX4242,chau,'atlanta',"Klaus",[Agenda("T","1630","1745")]) s12346 = Section(12346,CX4242,chau,'atlanta',"Klaus",[Agenda("T","1748","1749")]) s12347 = Section(12347,CX4242,chau,'atlanta',"Klaus",[Agenda("T","1600","1631")]) s31564 = Section(31564,ISYE2027,foley,'atlanta',"MRDC",[Agenda("T","0800","0915"),Agenda("R","0800","0915")]) s80430 = Section(80430,ISYE2027,foley,'atlanta',"IC",[Agenda("T","0800","0915"),Agenda("R","0800","0915")]) s83339 = Section(83339,ISYE2027,foley,'atlanta',"IC",[Agenda("T","1230","1745"),Agenda("W","1230","1345")]) '''some testing cases print(s12345.course.ID) print(s12346.professor.name) print(s12347.GPA) shed = Schedule() shed.addSection(s12345)
def main(): global POPULATION_SIZE global arrayofTime global GENES global LABS global ROOMS global PhysicsLAB prevFitness = 10 iterations = 0 fitness_Same_Count = 0 ifFound = False population = [] # current generation generation = 1 rooms = [ Room("CS-101", 70, False, False), Room("CS-102", 70, False, False), Room("CS-103", 70, False, False), Room("Lab-1", 70, True, False), Room("CS-104", 70, False, False), Room("CS-105", 70, False, False), Room("Lab-2", 70, False, True), Room("CS-106", 70, False, False) ] for r in rooms: if r.isLab == True: LABS.append(r) elif r.isPhysicsLab == True: PhysicsLAB.append(r) else: ROOMS.append(r) Prof1 = Professor("Shoaib", arrayofTime, "", 0, []) Prof2 = Professor( "adnan", [arrayofTime[6], arrayofTime[7], arrayofTime[8], arrayofTime[9]], "", 0, []) Prof3 = Professor("mirza", [ arrayofTime[3], arrayofTime[7], arrayofTime[9], arrayofTime[11], arrayofTime[7] ], "", 0, []) Prof4 = Professor( "Ali", [arrayofTime[0], arrayofTime[1], arrayofTime[10], arrayofTime[11]], "", 0, []) Prof5 = Professor("faiq", [arrayofTime[0], arrayofTime[1], arrayofTime[2]], "", 0, []) Prof6 = Professor("Jamal", arrayofTime, "", 0, []) Prof7 = Professor("Noman", [ arrayofTime[1], arrayofTime[2], arrayofTime[3], arrayofTime[4], arrayofTime[14] ], "", 0, []) Prof8 = Professor("Adeel", arrayofTime, "", 0, []) Prof9 = Professor("shahzain", [ arrayofTime[0], arrayofTime[1], arrayofTime[2], arrayofTime[3], arrayofTime[4], arrayofTime[5], arrayofTime[6] ], "", 0, []) Prof10 = Professor( "saim", [arrayofTime[0], arrayofTime[1], arrayofTime[2], arrayofTime[13]], "", 0, []) Prof11 = Professor("areeb", [ arrayofTime[3], arrayofTime[7], arrayofTime[9], arrayofTime[11], arrayofTime[7] ], "", 0, []) Prof12 = Professor("billal", [arrayofTime[1], arrayofTime[2]], "", 0, []) Prof13 = Professor( "irfan", [arrayofTime[0], arrayofTime[1], arrayofTime[10], arrayofTime[11]], "", 0, []) Prof14 = Professor("ismael", [arrayofTime[0], arrayofTime[1], arrayofTime[2]], "", 0, []) Prof15 = Professor("aarif", arrayofTime, "", 0, []) Prof16 = Professor("faris", [ arrayofTime[1], arrayofTime[2], arrayofTime[3], arrayofTime[4], arrayofTime[14] ], "", 0, []) course1 = { "Name": "MAD", "Professor": Prof1, "Capacity": 55, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": True, "isPhysics_Lab": False } course2 = { "Name": "Probability", "Professor": Prof2, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course3 = { "Name": "AI LAB", "Professor": Prof3, "Capacity": 30, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": True, "isPhysics_Lab": False } course4 = { "Name": "Multi", "Professor": Prof2, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course5 = { "Name": "POM", "Professor": Prof2, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course6 = { "Name": "AI", "Professor": Prof5, "Capacity": 30, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": True, "isPhysics_Lab": False } course7 = { "Name": "CAO", "Professor": Prof6, "Capacity": 60, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course8 = { "Name": "DCL", "Professor": Prof7, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course9 = { "Name": "FYP", "Professor": Prof8, "Capacity": 60, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course10 = { "Name": "Calculus", "Professor": Prof8, "Capacity": 60, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course11 = { "Name": "MAD", "Professor": Prof9, "Capacity": 55, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": True, "isPhysics_Lab": False } course12 = { "Name": "Probability", "Professor": Prof10, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course13 = { "Name": "AI LAB", "Professor": Prof11, "Capacity": 30, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": True, "isPhysics_Lab": False } course14 = { "Name": "Multi", "Professor": Prof12, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course15 = { "Name": "POM", "Professor": Prof13, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } course16 = { "Name": "AI", "Professor": Prof14, "Capacity": 30, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": True, "isPhysics_Lab": False } course17 = { "Name": "CAO", "Professor": Prof15, "Capacity": 60, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": True } course18 = { "Name": "DCL", "Professor": Prof16, "Capacity": 50, "Assigned-timeSlot": "", "Available_TimeSlots": [], "isClash": "", "roomAlotted": None, "isLab": False, "isPhysics_Lab": False } # courses = [course4, course2, course5] courses = [ course1, course2, course3, course4, course5, course6, course7, course8, course9, course10, course11, course12, course13, course14, course15, course16, course17, course18 ] # courses = [course1] GENES = courses for _ in range(POPULATION_SIZE): gnome = Individual.create_gnome() # print('GNOME',gnome) population.append(Individual(gnome)) print('Fitness-----', Individual(gnome).fitness) # Population Created while not ifFound: # sort the population in increasing order of fitness score population = sorted(population, key=lambda x: x.fitness) print('Fitness After-----', population[0].fitness) if population[0].fitness <= 0: ifFound = True # print('SELECTED GENERATION') # for i in population[0].chromosome: # print('', i['Name'], i['Assigned-timeSlot'] ) break elif population[0].fitness == prevFitness: fitness_Same_Count += 1 if fitness_Same_Count > 40: ifFound = True break elif generation >= 100: ifFound = True break else: prevFitness = population[0].fitness fitness_Same_Count = 0 new_generation = [] s = int((10 * POPULATION_SIZE) // 100) for ch in range(0, s, +1): ind = Individual(population[ch].mutation( population[ch].chromosome)) new_generation.append(ind) ns = int((90 * POPULATION_SIZE) // 100) # print(ns) # sub = ns - s for _ in range(ns): rand = randint(s, ns - 1) parent1 = population[rand] rand = randint(s, ns - 1) parent2 = population[rand] child = parent1.crossover(parent2) new_generation.append(child) population = new_generation # print('new', population[0].chromosome) # print('Generation: ', generation) # print('Population: ', population[0].chromosome) # print('Fitness: ', population[0].fitness) # print("Generation: {}\tDict: {}\tFitness: {}".format(generation, "".join(population[0].chromosome),population[0].fitness)) generation += 1 print('SELECTED GENERATION ') for ch in population[0].chromosome: print('Name : ', ch["Name"]) print('Professor : ', ch["Professor"].name) print('TimeSlot : ', ch["Assigned-timeSlot"]) # print('Available : ', ch["Available_TimeSlots"]) print('Room : ', ch["roomAlotted"].room) print('\n')
def primary_driver_logic(): comm = MPI.COMM_WORLD size = comm.Get_size() rank = comm.Get_rank() terrain_map = None score_map = None prof = None if rank == 0: t1 = time() print("Creating Terrain Map") terrain_map = TerrainMap("test.map") # print(terrain_map) print("Creating Score Map") score_map = ScoreMap(terrain_map) print("Creating Prof") prof = Professor(terrain_map) print("====STARTING PLACE====") print(prof) # possible_states = terrain_map.get_all_traversable_states() print("Generating Initial possible_states") # possible_states = prof.get_all_possible_states() terrain_map = comm.bcast(terrain_map, root=0) score_map = comm.bcast(score_map, root=0) prof = comm.bcast(prof, root=0) states = [] professor_surroundings = prof.get_surroundings() for x in range(rank, prof.terrain_map.width, size): for y in range(prof.terrain_map.height): point = Point(x, y) terrain = prof.terrain_map.get_tile(point) if terrain.is_traversable(): for dir in Directions: state = State(point, dir) if prof.is_possible_state(state, professor_surroundings): states.append(state) collected = comm.gather(states, root=0) if rank == 0: possible_states = [item for sublist in collected for item in sublist] print("Starting Amount of possible_states: ",len(possible_states)) i = 0 print_once = False print("===Starting Primary Loop===") while prof.state.point.y < terrain_map.height - 1: current_surroundings = prof.get_surroundings() next_possible_states = [] for possible_state in possible_states: if prof.is_possible_state(possible_state,current_surroundings): next_possible_states.append(possible_state) possible_states = next_possible_states if len(possible_states) > 1: if FILE_OUT: FileOut.to_png(terrain_map=terrain_map,possible_states=possible_states,professor=prof,file_name="steps/step" + str(i)) i += 1 print("Num possible states: ",len(possible_states)) # Now possible states have been trimmed down if len(possible_states) <= 1 and not print_once: print("++++++++++++++++++++++++++++++++++FOUND PROF++++++++++++++++++++++++++++++++++") print(score_map.get_tile(prof.state.point).score) print_once = True print(prof) print("isTraversible() ",terrain_map.get_tile(prof.state.point).is_traversable()) print("Getting Smart Move") move = get_smart_move(score_map, possible_states) print("Got Smart Move") # move = generate_random_valid_move(terrain_map, prof) print(move) prof.move(move) print("Moving All possible_states") for possible_state in possible_states: possible_state.move(move) if FILE_OUT: FileOut.to_png(terrain_map=terrain_map,possible_states=possible_states,professor=prof,file_name="steps/step" + str(i)) i += 1 if i > terrain_map.height * 1.25: print("NOT DONE YET BUT SAVING ISAAC'S SSD") break print("\n\n====RESTING PLACE===") print(prof) print("FOUND_PROF") t2 = time() print('time take: {} seconds'.format(t2 - t1)) return t2-t1
print("Saíndo da pesquisa de alunos...") break elif opcao_selecionada == 5: #Ver lista de professor for professor in lista_professores: print(f"{professor.nome} - {professor.matricula}") elif opcao_selecionada == 6: #Incluir um novo professor while True: nome_professor = input("Digite o nome do Professor\n") matricula_professor = input("Digite a matrícula do Professor\n") documento_professor = input("Digite o número do documento\n") professor = Professor( nome=nome_professor, documento=documento_professor, matricula=matricula_professor ) #Incluindo o documento no momento do construtor lista_professores.append(professor) #Insere um professor na lista print( f"O professor {professor.nome} foi inserido!" ) #Mostra para o usuário que o append, no caso o professor, foi feito #Solicitando a saída para o usuário controle_insert = input( "Deseja incluir mais um professor? (Digite 'n' ou 'N' para sair) \n" ) if len(controle_insert) == 1: if controle_insert == "n" or controle_insert == "N" or controle_insert == "S" or controle_insert == "s": if controle_insert.upper() == "N": print("Saíndo da inclusão de professores...")
for professor in lista_professores: print( f"Professor(a): {professor.nome} - disciplina: {professor.disciplina} - matrícula: {professor.matricula}" ) elif opcao_selecionada == 6: #Incluir um novo professor while True: nome_professor = input("Digite o nome do(a) Professor(a)\n") disciplina_professor = input( "Digite a disciplina do(a) Professor(a)\n") matricula_professor = input( "Digite a matrícula do(a) Professor(a)\n") professor = Professor( nome=nome_professor, disciplina=disciplina_professor, matricula=matricula_professor ) #Incluindo o documento no momento do construtor lista_professores.append(professor) #Insere um professor na lista print(f"O(A) professor(a) {professor.nome} foi inserido(a)!" ) #Mostra para o usuário que o append foi feito #Solicitando a saída para o usuário controle_insert_prof = input( "Deseja incluir mais um(a) professor(a)? (Digite 'n' ou 'N' para sair) \n" ) if len(controle_insert_prof) == 1: if controle_insert_prof == "n" or controle_insert_prof == "N" or controle_insert_prof == "S" or controle_insert_prof == "s": if controle_insert_prof.upper() == "N": print("Saindo da inclusão de professores...") break
#Objeto da calsse Pessoa p1 = Pessoa('João', '123', 20) #Imprimir dados print(p1.get_nome()) print(p1.get_cpf()) print(p1.get_idade()) #objeto em versao texto print(p1) #Objeto funcionario f1 = Funcionario('José', '456', 40, '0099', 2526.45, 'Biblioteca') print(f1.get_nome()) print(f1) #Objeto Aluno a1 = Aluno('Maria', '789', 19, 'Enfermagem', 'Noturno', '4512345') print(a1.get_nome()) print(a1) #Objeto Professor p1 = Professor('Mario', '159', 56, 'LTPI', '35789', 4054.59) print(p1.get_nome()) print(p1)
from Disciplina import Disciplina from Professor import Professor from Aluno import Aluno p1 = Professor(nome="fernando", ra="123456") d1 = Disciplina(nome="LP2", cargaHoraria=80, mensalidade=200, professor=p1) d2 = Disciplina(nome="LP3", cargaHoraria=80, mensalidade=200, professor=p1) a1 = Aluno(nome="Rechadson silva", email="joasjdo", ra="54321", celular="12342412", desconto=40) a1.adicionaDiciplina(d1) a1.adicionaDiciplina(d2) p1.adicionaDiciplina(d1) a1.diminuiDesconto(45) print("valor / hora disciplina:", d1.retornaValorHora()) print("carga horaria professor", p1.retornaCargaHoraria()) print("sobrenome", a1.retornaSobrenome()) print("valor mensalidade:", a1.retornaValorMensalidade()) print("carga horaria", a1.retornaCargaHoraria())
from pessoa import Pessoa from Funcionario import Funcionario from Professor import Professor from estudante import Estudante p1 = Pessoa('João', '123', 20) print(p1.get_nome()) print(p1.get_cpf()) print(p1.get_idade()) print(p1) f1 = Funcionario('José', '456', 40, '0099', 2526.45, 'Biblioteca') print(f1) t1 = Professor('Bila', '789', 50, '0100', 3000, 'Gastronomia', 'Degustação') e1 = Estudante('Rafael', '017', 22, '1717', 'Ciência da Computação', 'Quarto semestre') print(t1) print(e1)
class TestProfessor(TestCase): def setUp(self): self.obj = Professor("William", "Adams", "*****@*****.**", 65000, "Computer Science") self.class_obj = Group("Cos101", 3) def test_setDepartment_match(self): self.assertEqual(self.obj.get_department(), "Computer Science") self.obj.set_department("Cos") self.assertEqual(self.obj.get_department(), "Cos") def test_setDepartment_noMatch(self): self.assertEqual(self.obj.get_department(), "Computer Science") self.obj.set_department("434") self.assertEqual(self.obj.get_department(), "No_department") def test_setPay_success(self): self.assertEqual(self.obj.get_pay(), 65000) self.obj.set_pay(30000) self.assertEqual(self.obj.get_pay(), 30000) def test_setPay_fail(self): self.assertEqual(self.obj.get_pay(), 65000) self.obj.set_pay("30000") self.assertEqual(self.obj.get_pay(), 10000)
def professores_menu(): print(""" --- SISTEMA ACADEMICO / PROFESSORES --- =============================================== --- Escolha uma opção --- =============================================== 1 - Listar 2 - Adicionar 3 - Deletar 4 - Atualizar 0 - Voltar ============================================== """) professor = Professor() while True: opcao = input("Digite a opção: ") if opcao == "1": professor.lsitar() professores_menu() if opcao == "2": professor.set_nome(input("Digite o nome: ")) professor.set_cpf(input("Digite o cpf: ")) professor.set_departamento(input("Digite o departamento: ")) if professor.adicionar(): print('\n--- Professor já existe ---\n') professores_menu() else: print("\n--- Professor adicionado com sucesso! ---\n") professores_menu() if opcao == "3": professor.set_cpf(input("Digite o cpf: ")) if professor.apagar(): print('\n--- Professor nao existente. ---\n') professores_menu() else: print("\n--- Professor deletado ---\n") professores_menu() if opcao == "4": professor.set_cpf(input("Digite o cpf: ")) novo_nome = input("Digite o nome atualizado: ") novo_cpf = input("Digite o cpf atualizado: ") novo_departamento = input("Digite o departamento atualizado: ") if professor.atualizar(novo_nome, novo_cpf, novo_departamento): print("\n--- Professor não registrado ---") professores_menu() else: print("\n--- Professor atualizado com sucesso ---") professores_menu() if opcao == "0": home_menu() else: print("\n--- Opção inválido por favor digite novamente ---\n") professores_menu() continue
def addProfessor(self, Professor): if (Professor.getId() in self.professors): pass else: self.professors[Professor.getId()] = Professor