Esempio n. 1
0
def DPmem():
    while True:
        try: 
            print("How much memory do you want the machine to have: [1-50] [C/c to cancel]")
            maxMem = input("> ")
            if maxMem.lower() == "c":
                return
            maxMem = int(maxMem)
            if maxMem < lowerBoundMemory or maxMem > upperBoundMemory:
                raise ValueError
            Machine = Memory.DP(maxMem)
            jobCounter = 0
            break
        except ValueError:
            print("ERROR: Please input a valid choice")
    
    while True:
        print()
        Machine.printMemory(freeSymbol,takenSymbol)
        Machine.printJobs()
        print("\n[1] Add job")
        print("[2] Deallocate job")
        print("[3] EXIT")

        option = "0"
        optionChoices = ["1","2","3"]
        while option not in optionChoices:
            print("Choose an option")
            option = input("> ")
            if option not in optionChoices:
                print("ERROR: Please pick a valid option")
        
        if option == "1":
            addJob(Machine, "DP")
        elif option == "2":
            if len(Machine.objects) == 0:
                print("ERROR: No jobs to deallocate")
            else:
                deleteJob(Machine, "DP")
        elif option == "3":
            return