def app(): srepo = SRepo("stud.txt") grepo = Grepo(srepo, "grade.txt") scntr = SController(srepo) gcntr = GradeController(grepo, srepo) ui = UI(scntr, gcntr) ui.start()
def main(self): StudRepo = StudentFileRepo("student.txt") StudContr = StudentController(StudRepo, StudentValidator) print(StudRepo) labrep = LabRepo("laboratory.txt", StudRepo) LabContr = LabController(labrep, StudRepo) print(labrep) cons = UI(StudContr, LabContr) cons.start()
def run(): graph, ep = loadFromFile() ui = UI() utils = Utils() ui.clear() while True: opt = ui.mainMenu() if opt == 0: ui.clear() break elif opt == 1: ui.clear() startVertex = ui.readVertex("Enter start vertex: ", graph.getVertices()) if startVertex != -1: endVertex = ui.readVertex("Enter end vertex: ", graph.getVertices()) if endVertex != -1: utils.BellmanFord(graph, ep, startVertex, endVertex) ui.wait4enter() elif opt == 2: ui.showG_or_EP(graph) elif opt == 3: ui.showG_or_EP(ep)
def run(): graph = loadFromFile() ui = UI() utils = Utils() ui.clear() while True: opt = ui.mainMenu() if opt == 0: ui.clear() break elif opt == 1: ui.clear() colorList = utils.colorGraph(graph) ui.showColoredGraph(colorList) ui.wait4enter() elif opt == 2: ui.clear() print graph ui.wait4enter()
def run(): loadFromFile() copyGraph = deepcopy(graph) copyEP = deepcopy(ep) ui = UI() ui.clear() while True: opt = ui.mainMenu() if opt == 0: ui.clear() break elif opt == 1: ui.clear() ui.numberVertices(graph.getNbrVertices()) ui.wait4enter() elif opt == 2: ui.clear() startVertex = ui.readVertex("Enter start vertex: ", graph.getDictKeys()) if startVertex != -1: endVertex = ui.readVertex("Enter end vertex: ", graph.getDictKeys()) if endVertex != -1: if graph.isEdge(startVertex, endVertex): print "Yes. There is an edge from", startVertex, "to", endVertex else: print "No. There dosen't exists an edge from", startVertex, "to", endVertex ui.wait4enter() else: ui.clear() else: ui.clear() elif opt == 3: ui.clear() vertex = ui.readVertex("Enter vertex: ", graph.getDictKeys()) if vertex != -1: x = graph.vertexDegree(vertex) print "In degree:",x[0] print "Out degree:", x[1] ui.wait4enter() else: ui.clear() elif opt == 4: ui.clear() vertex = ui.readVertex("Enter vertex: ", graph.getDictKeys()) if vertex != -1: print graph.outbound(vertex) ui.wait4enter() else: ui.clear() elif opt == 5: ui.clear() vertex = ui.readVertex("Enter vertex: ", graph.getDictKeys()) if vertex != -1: print graph.inbound(vertex) ui.wait4enter() else: ui.clear() elif opt == 6: ui.clear() startVertex = ui.readVertex("Enter start vertex: ", graph.getDictKeys()) if startVertex != -1: endVertex = ui.readVertex("Enter end vertex: ", graph.getDictKeys()) if endVertex != -1: if graph.isEdge(startVertex, endVertex): ep.retrieveProperty(startVertex, endVertex) ui.wait4enter() else: print "That edge does not exist!" ui.wait4enter() else: ui.clear() else: ui.clear() elif opt == 7: ui.clear() startVertex = ui.readVertex("Enter start vertex: ", graph.getDictKeys()) if startVertex != -1: endVertex = ui.readVertex("Enter end vertex: ", graph.getDictKeys()) if endVertex != -1: if graph.isEdge(startVertex, endVertex): value = raw_input("Enter value: ").strip() ep.modifyProperty(startVertex, endVertex, value) ui.clear() else: print "That edge does not exist!" ui.wait4enter() else: ui.clear() else: ui.clear() elif opt == 8: ui.clear() startVertex = ui.readVertex("Enter start vertex: ", graph.getDictKeys()) if startVertex != -1: endVertex = ui.readVertex("Enter end vertex: ", graph.getDictKeys()) if endVertex != -1: if graph.isEdge(startVertex, endVertex): print "That edge already exists!" ui.wait4enter() else: value = raw_input("Enter value: ").strip() graph.addEdge(startVertex, endVertex) ep.addEP((startVertex, endVertex), value) ui.clear() else: ui.clear() else: ui.clear() elif opt == 9: ui.clear() startVertex = ui.readVertex("Enter start vertex: ", graph.getDictKeys()) if startVertex != -1: endVertex = ui.readVertex("Enter end vertex: ", graph.getDictKeys()) if endVertex != -1: if graph.isEdge(startVertex, endVertex): graph.removeEdge(startVertex, endVertex) toBeRemovedEdges = [] toBeRemovedEdges.append((startVertex, endVertex)) ep.removeEdges(toBeRemovedEdges) else: print "There dosen't exists an edge from", startVertex, "to", endVertex ui.wait4enter() ui.clear() elif opt == 10: ui.clear() vertex = ui.readNewVertex("Enter vertex (positive integer): ", graph.getDictKeys()) if vertex != -1: graph.addVertex(vertex) ui.clear() elif opt == 11: ui.clear() vertex = ui.readVertex("Enter vertex: ", graph.getDictKeys()) if vertex != -1: toBeRemovedEdges = graph.removeVertex(vertex) ep.removeEdges(toBeRemovedEdges) ui.clear() elif opt == 12: ui.clear() ui.showG_or_EP(copyGraph) ui.wait4enter() elif opt == 13: ui.clear() ui.showG_or_EP(copyEP) ui.wait4enter() elif opt == 14: ui.clear() ui.showG_or_EP(graph) ui.wait4enter() elif opt == 15: ui.showG_or_EP(ep) ui.wait4enter()
from console import UI ui = UI() ui.run()
disciplineCtrl.addDiscipline(Discipline(3, "physics education")) disciplineCtrl.addDiscipline(Discipline(11, "computer science")) # gradeCtrl = GradeCtrl(gradeRepo) gradeCtrl.addGrade(Grade(1, "Ana", 1, "maths", 3)) gradeCtrl.addGrade(Grade(10, "Tini", 2, "maths", 8)) gradeCtrl.addGrade(Grade(11, "Toni", 2, "maths", 6)) gradeCtrl.addGrade(Grade(3, "Ion", 1, "english", 2)) gradeCtrl.addGrade(Grade(2, "Gigi", 1, "english", 7.5)) gradeCtrl.addGrade(Grade(4, "Mihnea", 1, "english", 8)) gradeCtrl.addGrade(Grade(5, "Gheorghe", 1, "english", 9)) gradeCtrl.addGrade(Grade(6, "Hagi", 1, "english", 6)) gradeCtrl.addGrade(Grade(7, "Urko", 1, "english", 9)) gradeCtrl.addGrade(Grade(8, "Bastos", 1, "english", 10)) gradeCtrl.addGrade(Grade(5, "Gheorghe", 1, "english", 8)) gradeCtrl.addGrade(Grade(6, "Hagi", 1, "english", 7)) gradeCtrl.addGrade(Grade(7, "Urko", 1, "english", 9)) gradeCtrl.addGrade(Grade(8, "Bastos", 1, "english", 10)) undoRedo = UndoRedo(studentCtrl, disciplineCtrl, gradeCtrl) undoRedoCtrl = UndoRedoCtrl(undoRedo) file = StudentFileRepository() controllerFile = cFile(file) ui = UI(studentCtrl, disciplineCtrl, gradeCtrl, undoRedoCtrl, controllerFile) ui.mainMenu()
def run(): graph = loadFromFile() ui = UI() utils = Utils() ui.clear() visited = [] while True: opt = ui.mainMenu() if opt == 0: ui.clear() break elif opt == 1: ui.clear() ui.showCC(utils.connected_components(graph)) ui.wait4enter() elif opt == 2: ui.clear() print graph ui.wait4enter()
from game import Board, Game from console import UI from AIalgorithms import BasicAlgorithm b = Board() AI = BasicAlgorithm() g = Game(AI, b) start = UI(g) start.start()