QUIZ 8
COMP9021 PRINCIPLES OF PROGRAMMING
$ python3
...
>>> from quiz_8 import *
>>> the_horizons = Building(10, 'A B C D')
>>> the_horizons
Building(10, 'A B C D')
>>> print(the_horizons)
Building with 11 floors accessible from entries: A, B, C, D
>>> Building.number_created
1
>>> the_spike = Building(37, '1')
>>> the_spike
Building(37, '1')
>>> print(the_spike)
Building with 38 floors accessible from entries: 1
>>> Building.number_created
2
>>> the_seaside = Building(6, 'A B Z')
>>> the_seaside
Building(6, 'A B Z')
>>> print(the_seaside)
Building with 7 floors accessible from entries: A, B, Z
>>> Building.number_created
3
>>> the_horizons.go_to_floor_from_entry(-1, 'A', 4)
...
quiz_8.BuildingError: That makes no sense!
>>> the_horizons.go_to_floor_from_entry(11, 'A', 4)
...
quiz_8.BuildingError: That makes no sense!
>>> the_horizons.go_to_floor_from_entry(0, 'Z', 4)
...
quiz_8.BuildingError: That makes no sense!
>>> the_horizons.go_to_floor_from_entry(0, 'B', 0)
...
quiz_8.BuildingError: That makes no sense!
>>> the_horizons.go_to_floor_from_entry(0, 'B', 4)
>>> compare_occupancies(the_horizons, the_spike)
There are more occupants in the first building.
>>> the_spike.go_to_floor_from_entry(17, '1', 4)
>>> compare_occupancies(the_horizons, the_spike)
There is the same number of occupants in both buildings.
Date: Trimester 3, 2024.
2 COMP9021 PRINCIPLES OF PROGRAMMING
>>> the_spike.leave_floor_from_entry(17, '1', 0)
...
quiz_8.BuildingError: That makes no sense!
>>> the_spike.leave_floor_from_entry(17, '1', 5)
...
quiz_8.BuildingError: There aren't that many people on that floor!
>>> the_spike.leave_floor_from_entry(17, '1', 3)
>>> the_horizons.leave_floor_from_entry(0, 'A', 1)
...
quiz_8.BuildingError: There aren't that many people on that floor!
>>> the_horizons.leave_floor_from_entry(0, 'B', 1)
>>> the_horizons.leave_floor_from_entry(0, 'B', 1)
>>> the_horizons.leave_floor_from_entry(0, 'B', 1)
>>> compare_occupancies(the_horizons, the_spike)
There is the same number of occupants in both buildings.
>>> the_horizons.leave_floor_from_entry(0, 'B', 1)
>>> compare_occupancies(the_horizons, the_spike)
There are more occupants in the second building.
>>> the_seaside.go_to_floor_from_entry(3, 'B', 1)
>>> the_seaside.go_to_floor_from_entry(3, 'B', 1)
Wait, lift has to go down 3 floors...
>>> the_seaside.go_to_floor_from_entry(3, 'B', 1)
Wait, lift has to go down 3 floors...
>>> the_seaside.go_to_floor_from_entry(3, 'B', 1)
Wait, lift has to go down 3 floors...
>>> the_seaside.leave_floor_from_entry(3, 'B', 2)
>>> the_seaside.leave_floor_from_entry(3, 'B', 2)
Wait, lift has to go up 3 floors...
>>> the_seaside.go_to_floor_from_entry(4, 'A', 10)
>>> the_seaside.go_to_floor_from_entry(5, 'A', 10)
Wait, lift has to go down 4 floors...
>>> the_seaside.go_to_floor_from_entry(2, 'A', 10)
Wait, lift has to go down 5 floors...
>>> the_seaside.leave_floor_from_entry(4, 'A', 2)
Wait, lift has to go up 2 floors...
>>> the_seaside.go_to_floor_from_entry(1, 'A', 10)
>>> the_seaside.leave_floor_from_entry(5, 'A', 2)
Wait, lift has to go up 4 floors...
>>> the_seaside.go_to_floor_from_entry(5, 'A', 10)
>>> the_seaside.leave_floor_from_entry(3, 'B', 2)
...
quiz_8.BuildingError: There aren't that many people on that floor!
>>> the_seaside.leave_floor_from_entry(2, 'A', 2)
Wait, lift has to go down 3 floors...