Pizza Program /* */ /* * A program that makes a pizza to demonstrate the elements of programming * Programming concepts include: * Comments versus key words versus code * Bowls as a metaphor for variables * Actual parameter (hamBowl) versus a formal parameter (nameOfBowl) * Function declaration such as main() with start-block { and end-block } delimiters * System library functions: start timer, test timer, and wait * Do-while loop * Function calls with "make" and returning the contents of bowls with "return" * Boolean "if" tests and conditional return from a function * Assignment of returned bowl contents to variables * Sequential reuse of variables with "musBowl" */ global variable bigBowl; /* Global variables are visible to all functions. */ /* Entry point of program (can be located anywhere). */ /* Start program by typing "pizza 2" where 2 is the number of pizza to make. */ /* Run-time environment passes in the number 2 to the variable "numberOfPizzas" */ main (variable numberOfPizzas) { /* Local variables can only be seen from within a function. */ local variable musBowl, motBowl, hamBowl, sausBowl, oliveBowl, onionBowl; do { make dough (bigBowl); /* Call the function "dough()' with a global variable */ make setTimer (45 minutes); /* Call the start timer function so we know when the dough is ready. */ oliveBowl = make chopOrSlice (slice is TRUE, ripeOlives); onionBowl = make chopOrSlice (slice is FALSE, onion); musBowl = make chopOrSlice (slice is FALSE, mushroom); musBowl = make saute (musBowl); hamBowl = make saute (hamburger); sausBowl = make saute (sausage); motBowl = make shred (mozzarella); if time not equal 45 minutes { wait; /* dough must rise before we can use it */ } make crust (bigBowl); make spread (pizzaSauce); make spread (hamBowl); make spread (sausBowl); make spread (onionBowl); make spread (oliveBowl); make spread (motBowl); make bake (30 minutes); } while (decrement numberOfPizzas and not equal to zero); } dough (variable namOfBowl) { place yeast in namOfBowl; add 1 cup warm water to namOfBowl; wait 5 minutes; add 1 teaspoon salt, 1 teaspoon sugar to namOfBowl; add 1 tablespoon oil to namOfBowl; add 1.5 cups flour to namOfBowl; mix with wisk or spoon until paste; add 1.5 cups of flour to namOfBowl; mix with hands; need gently until until dough; } chopOrSlice (flag slice, variable bowl) { local variable bowl-stuff; empty bowl onto cutting board; hold bowl-stuff in left hand, knife in right hand; slice bowl-stuff right to left moving fingers so they are not cut; if (slice is TRUE) { place bowl-stuff in bowl; return bowl; } else /* slice is FALSE, so chop */ rotate cutting board 90 degrees; hold bowl-stuff slices in left hand, knife in right hand; slice bowl-stuff right to left moving fingers so they are not cut; place bowl-stuff in bowl; return bowl; } saute (variable bowl) { local variable bowl-stuff; place frying pan on stove; set burner to medium; add oil to frying pan; empty bowl into frying pan; stir bowl-stuff until brown; drain grease from frying pan; place bowl-stuff in bowl; return bowl; } crust () { /* Yet to be implemented */ } spread (variable bowl) { /* Yet to be implemented */ } bake (variable bowl) { /* Yet to be implemented */ }