-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentities.py
More file actions
87 lines (70 loc) · 2.66 KB
/
entities.py
File metadata and controls
87 lines (70 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
"""CSC148 Assignment 1 - People and Elevators
=== CSC148 Fall 2018 ===
Department of Computer Science,
University of Toronto
=== Module description ===
This module contains classes for the two "basic" entities in this simulation:
people and elevators. We have provided basic outlines of these two classes
for you; you are responsible for implementing these two classes so that they
work with the rest of the simulation.
You may NOT change any existing attributes, or the interface for any public
methods we have provided. However, you can (and should) add new attributes,
and of course you'll have to implement the methods we've provided, as well
as add your own methods to complete this assignment.
Finally, note that Person and Elevator each inherit from a kind of sprite found
in sprites.py; this is to enable their instances to be visualized properly.
You may not change sprites.py, but are responsible for reading the documentation
to understand these classes, as well as the abstract methods your classes must
implement.
"""
from __future__ import annotations
from typing import List
from sprites import PersonSprite, ElevatorSprite
class Elevator(ElevatorSprite):
"""An elevator in the elevator simulation.
Remember to add additional documentation to this class docstring
as you add new attributes (and representation invariants).
=== Attributes ===
passengers: A list of the people currently on this elevator
=== Representation invariants ===
"""
passengers: List[Person]
class Person(PersonSprite):
"""A person in the elevator simulation.
=== Attributes ===
start: the floor this person started on
target: the floor this person wants to go to
wait_time: the number of rounds this person has been waiting
=== Representation invariants ===
start >= 1
target >= 1
wait_time >= 0
"""
start: int
target: int
wait_time: int
def get_anger_level(self) -> int:
"""Return this person's anger level.
A person's anger level is based on how long they have been waiting
before reaching their target floor.
- Level 0: waiting 0-2 rounds
- Level 1: waiting 3-4 rounds
- Level 2: waiting 5-6 rounds
- Level 3: waiting 7-8 rounds
- Level 4: waiting >= 9 rounds
"""
pass
if __name__ == '__main__':
import python_ta
python_ta.check_all(config={
'extra-imports': ['sprites'],
'max-nested-blocks': 4
})