- To recognize which type of loop is appropriate to use in various situations;
- To correctly nest loops in order to complete the task in the most efficient way.
Your Task, Your Challenge
Write your code so that the robot delivers all the meals from the kitchen to the school.
You must write your code so that the robot delivers all the meals from the kitchen to the school. The number of meals per day varies, but there is always at least one. The number of meals that will fit in the van is unknown and may vary from one van to another. At the start, the van is empty, the doors are closed, and it is located near the school. This is where it should be located at the end of your program.
The robot can carry out 3 actions:
- go ('where'); where 'where' or is either 'kitchen' or 'school';
- vanMeal ('what'); where 'what' refers to the 'loading' into or 'unloading' from the van of one meal at a time;
- vanDoors ('what'); where 'what' can be 'open' or 'close'.
The robot can also perform 3 tests:
- vanEmpty () tests whether the van is completely empty;
- vanFull () tests whether the van is completely full and therefore cannot accept any more meals;
- atLeast1MealInKitchen () tests if there is at least one meal available on the kitchen shelves.
As you can see, in this exercise, you will need to use several repetition statements:
- - 1 to make the trips;
- - 1 to load the van;
- - 1 to unload the van.
You must put the repetitive tasks in the correct order to succeed in this exercise.