State and Types
You have been introduced to state with examples in the lecture, i.e. the lightbulb and traffic lights. This week’s labs build on the concept of states and allow you to explore how abstract objects are given a state by defining attributes and assigning values to those attributes.
In the lightbulb example, the state was either on or off. In the traffic light example, there were more than 2 possible states. There were more possible states because there were more attributes (three lights as opposed to one).
An objects state may be in one of many combinations, let’s consider a simple binary example: a binary bit can only be in one of two states, either 1 or 0, but if we have two binary bits and group them together we introduce more possible states: 00, 01, 10 and 11.
When defining a state, we are interested in the values associated with the attributes, let’s come back to our traffic light example, our attributes are red light, yellow light and green light and the states are on or off (to keep things simple). How many different states could there be?