It is late at night, and you decide to get a glass of milk before bed. Try to write
pseudocode describing the process of going to the kitchen and getting the milk. Be
very specific and make sure you have all actions in the correct sequence. For example,
remember you must open the refrigerator door before you reach in to retrieve the milk
container. What if there is no glass in the cupboard? Did you check whether the glass
was right side up before you started pouring? Now consider how many small
decisions you make every day, and consider how involved it would be to write a
program to instruct a robot to do the things you do in a day!
1. Is the light one?
2. if (yes) then navigate the kitchen
3. else (find the electric board switch and press on and then navigate the kitchen)
4. Find the fridge
5. open the fridge door
find the milk pot
6. if(found) then navigate the glass
7. else(search the next pot)
8. close the fridge door
9. Find the glass in kitchen
10. if found then pour the milk into the glass
11. if not, then search on other place
12. Is pot, empty?
13. if(yes) then put the pot in washbasin
14. else repeat step 4 to 8
15. drink the milk
16. if glass is empty then put the glass in washbashin
else repeat step 4 to 8
17. navigate the bed room
18. switch off the light
19 sleep.
Comments
Leave a comment