Lecture notes for the Introduction to Computer Science I by James
Tam
Return
to the course web page
Description of the function and procedure skeletons for
"Squirt the Weed"
Main: The starting point of execution for the program. Location
where the array representing the 'garden' is declared.
Intro: Describes how the program works for the player.
Clear: Initializes the garden to spaces.
GenerateCoordinates: randomly generates a row and column value coordinate
for each weed that is still left in the game.
IsEmpty: A function that determines if a particular array element contains
a weed or not.
GrowWeeds: For each row, column pair that was generated in generated in 'generateCoordinates',
this procedure will be responsible for making a weed appear at that location
(grow).
Display: shows the current state of the array using numbered bounding
lines.
InBounds: A function that determines if a row or column value is within
the bounds of the array.
GetGuess: Prompts the player to enter a row, column pair location to
squirt the garden.
ProcessGuess: Based on the row, column value entered by the player, this
procedure will determine if a weed gets squirted or not.
DisplayWin: Displays a suitable congratulatory message if the player
managed to squirt all the weeds before the time has elapsed.