Class Name | Attributes | Methods |
---|---|---|
Carpark |
name, | init |
lacation, | update_temperature | |
max_bays, | publicsh_car_status | |
occupied, | add_car | |
displays, | remove_car | |
bays, | is_full | |
cars | register_display | |
Sensor |
car_park | init |
_read_plate | ||
detect | ||
update_car_park | ||
Display |
temperature, | init |
available_bays, | display_board | |
show_full, | ||
banner | ||
Config |
file_name | init |
config | ||
`test_carpark' | self.car_park | test_carpark_is_instantiated |
test_display_is_instantiated | ||
test_sensor_is_instantiated | ||
setUp |
Like temperature, I think the carpark class manages time. This is because Carpark thinks that the display is updateed and the display class
Properties: A characteristic or characteristic of an object. Regarding this project, for example, assuming that there is a car class, it can be the color and model for it.
Property: Among the above attributes, it can be said to be an external accessible attribute. You can read or write values of methods and perform additional actions when accessing properties.
2. Why do you think we used a dictionary to hold the data we passed the display? List at least one advantage and one disadvantage of this approach.
Advantage: It is useful for processing various types of data because it stores data in the form of key-value.
Disadvantages: When the code becomes complicated, it can be difficult to figure out what data is stored at a glance.
The car park register method should accept a Sensor
or Display
object. It should raise a TypeError
if the object is neither a Sensor
nor a Display
. Before proceeding, think about where you would test this behaviour. Should you test it in the CarPark
unit tests or the Sensor
unit tests? Why?
Registering the objects (sensors and displays) in the CarPark class and updating their status seems more appropriate within the context of the CarPark class. This is because the sensors detect the entry and exit of vehicles, notifying the CarPark, which, in turn, updates the displays. Given this flow of interaction, the responsibility for registering and updating lies with the CarPark. Therefore, testing these actions in the unit tests for the CarPark class is deemed suitable.