Example #1
0
def mainCommand():
    ApartmentList = []
    UndoList = []
    AddApartments(ApartmentList)
    #testAddApartment(ApartmentList)
    #testRemoveApartment(ApartmentList)
    while True:
        cmd = readCommand()
        command = cmd[0]
        params = cmd[1]

        if command == 'add':
            AddApartment(ApartmentList, params, UndoList)
        elif command == 'remove':
            removeApartment(ApartmentList, params, UndoList)
        elif command == 'list':
            listApartments(ApartmentList, params)
        elif command == 'replace':
            replaceExpense(ApartmentList, params, UndoList)
        elif command == 'sum':
            sumExpense(ApartmentList, params)
        elif command == 'max':
            maxExpense(ApartmentList, params)
        elif command == 'sort':
            sort(ApartmentList, params)
        elif command == 'filter':
            filterApartments(ApartmentList, params, UndoList)
        elif command == 'undo':
            ApartmentList = undo(ApartmentList, UndoList)
        elif command == 'help':
            HelpMenu()
        elif command == 'exit':
            break
        else:
            print("Invalid command!")
Example #2
0
def RemoveTypeOfApartmentUI(ApartmentList, UndoList):
    '''
    Removes all the apartments of a certain type
    Input: ApartmentList
    Output: -
    '''
    typeOfApartment = input("Please type the type of expense : ")
    removeApartment(ApartmentList, ['', typeOfApartment], UndoList)
Example #3
0
def RemoveApartmentUI(ApartmentList, UndoList):
    '''
    Removes an apartment
    Input: ApartmentList
    Output: -
    '''
    while True:
        try:
            apartment = input("Please type the apartment : ")
            apartment = int(apartment)
            break
        except:
            print("Error ! Please type correctly")
    removeApartment(ApartmentList, ['', apartment], UndoList)
Example #4
0
def testRemoveApartment(ApartmentList):
    params = ['remove', '17']
    removeApartment(ApartmentList, params)
    assert (len(ApartmentList) == 11)
    params = ['remove', '19']
    removeApartment(ApartmentList, params)
    assert (len(ApartmentList) == 11)
    params = ['remove', '20', 'to', '30']
    removeApartment(ApartmentList, params)
    assert (len(ApartmentList) == 11)
    params = ['remove', '16', 'to', '18']
    removeApartment(ApartmentList, params)
    assert (len(ApartmentList) == 9)
    params = ['remove', 'gas']
    removeApartment(ApartmentList, params)
    assert (len(ApartmentList) == 4)
Example #5
0
def RemoveSeveralApartmentsUI(ApartmentList, UndoList):
    '''
    Removes several apartments between two given values
    Input: ApartmentList
    Output: -
    '''
    while True:
        try:
            argumentOne = input("Please type the start apartment : ")
            argumentOne = int(argumentOne)
            break
        except:
            print("Error ! Please type correctly")
    while True:
        try:
            argumentTwo = input("Please type the end apartment : ")
            argumentTwo = int(argumentTwo)
            break
        except:
            print("Error ! Please type correctly")
    removeApartment(ApartmentList, ['', argumentOne, 'to', argumentTwo],
                    UndoList)