Description
COMP9021 PRINCIPLES OF PROGRAMMING
$ python3
>>> from quiz_8 import *
>>> DarkCorridor(-1)
Traceback (most recent call last):
…
quiz_8.DarkCorridorError: The length of the corridor should be strictly positive
>>> DarkCorridor(0)
Traceback (most recent call last):
…
quiz_8.DarkCorridorError: The length of the corridor should be strictly positive
>>> corridor = DarkCorridor(3)
>>> corridor
DarkCorridor(3)
>>> print(corridor)
⬜ ⬜ ⬜
>>> student_before_exam = Pacer(‘John’, corridor)
>>> student_before_exam
Pacer(‘John’, DarkCorridor(3))
>>> print(student_before_exam)
John in ⬜ ⬜ ⬜
>>> student_before_exam.now_here_in_dark_corridor()
▶ ⬜ ⬜
>>> student_before_exam.pace(1)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ▶ ⬜
>>> student_before_exam.pace(1)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ⬜ ▶
>>> student_before_exam.pace(1)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ⬜ ◀
>>> student_before_exam.pace(1)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ◀ ⬜
>>> student_before_exam.pace(1)
>>> student_before_exam.now_here_in_dark_corridor()
◀ ⬜ ⬜
>>> student_before_exam.pace(1)
>>> student_before_exam.now_here_in_dark_corridor()
▶ ⬜ ⬜
2 COMP9021 PRINCIPLES OF PROGRAMMING
>>> student_before_exam.pace(2)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ⬜ ▶
>>> student_before_exam.pace(2)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ◀ ⬜
>>> student_before_exam.pace(2)
>>> student_before_exam.now_here_in_dark_corridor()
▶ ⬜ ⬜
>>> student_before_exam.pace(3)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ⬜ ◀
>>> student_before_exam.pace(3)
>>> student_before_exam.now_here_in_dark_corridor()
▶ ⬜ ⬜
>>> student_before_exam.pace(4)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ◀ ⬜
>>> student_before_exam.pace(4)
>>> student_before_exam.now_here_in_dark_corridor()
⬜ ⬜ ▶
>>> student_before_exam.pace(10)
>>> student_before_exam.now_here_in_dark_corridor()
▶ ⬜ ⬜
>>> mother_before_exam = Pacer(‘Helen’, corridor)
>>> print(mother_before_exam)
Helen in ⬜ ⬜ ⬜
>>> mother_before_exam.now_here_in_dark_corridor()
▶ ⬜ ⬜
>>> mother_before_exam.pace(36)
>>> compare_stress(student_before_exam, mother_before_exam) John and Helen are both as stressed (36 steps).
>>> longer_corridor = DarkCorridor(8)
>>> longer_corridor
DarkCorridor(8) >>> print(longer_corridor)
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
>>> father_before_exam = Pacer(‘Jim’, longer_corridor)
>>> father_before_exam
Pacer(‘Jim’, DarkCorridor(8))
>>> father_before_exam.pace(13)
>>> father_before_exam.pace(4)
>>> father_before_exam.now_here_in_dark_corridor()
⬜ ▶ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
>>> compare_stress(father_before_exam, student_before_exam) John (36 steps) is more stressed than Jim (17 steps). >>> print(student_before_exam)
John in ⬜ ⬜ ⬜
Reviews
There are no reviews yet.