'''class_worksheet_elevator.py
Practice making a class for an elevator that carries people and has a weight limit
Oliver W. Layton
CS 151: Computational Thinking: Visual Media
Spring 2021
'''


class Elevator:
    def __init__(self, max_weight=400):
        '''
        TODO: Create IVs for:
            - max weight capacity
            - list of people names on elevator (initially empty list)
            - list of people weights on elevator (initially empty list)
        '''
        self.maxWeight = max_weight
        self.names = []
        self.weights = []

    def getMaxWeight(self):
        '''TODO: Write this get method
        '''
        return self.maxWeight

    def getRiderNames(self):
        '''TODO: Write this get method
        '''
        return self.names

    def getRiderWeights(self):
        '''TODO: Write this get method
        '''
        return self.weights

    def setMaxWeight(self, newMaxWeight):
        '''TODO: Write this set method
        '''
        self.maxWeight = newMaxWeight

    def addRider(self, name, weight):
        '''TODO: Write this method
        This method is called when someone gets on the elevator
        It should append the name and weight to the appropriate IV lists.
        '''
        self.names.append(name)
        self.weights.append(weight)

    def findTotalRiderWeight(self):
        '''TODO: Write this method
        This method should determine and return the total weight of all the people
        in the elevator.
        '''
        total = 0
        for wt in self.weights:
            total += wt
        return total

    def isCapacityOk(self):
        '''TODO: Write this method
        This method should return True if the weight of all the people on the elevator
        is BELOW the max capacity, otherwise return False.
        '''
        if self.findTotalRiderWeight() < self.maxWeight:
            return True
        else:
            return False


if __name__ == '__main__':
    vator = Elevator()
    vator.addRider('Jane', 100)
    vator.addRider('Jim', 100)
    vator.addRider('Bob', 100)

    print('Current weight of all riders:', vator.findTotalRiderWeight())
    print('The limit is:', vator.getMaxWeight())
    print('Do we have room for another rider on the elevator?', vator.isCapacityOk())

    vator.addRider('Sue', 100)
    print('Current weight of all riders:', vator.findTotalRiderWeight())
    print('Do we have room for another rider on the elevator?', vator.isCapacityOk())
