Sunday, April 26, 2009

01A_BEDZRA_Pseudo-Code: washing a plate

for humans

make soapy water
put plate in
scrub
rinse plate with fresh water

for a computer

function make soapyWater:
with kitchenSink
cover wasteWater drain
turn coldWater tap to ,,on"
if kitchenSink = 25%full:
turn coldWater tap to ,,off"
lift liquid soap
with liquidSoap:
position over kitchenSink
turn -180°
add 4 drops to coldWater
turn 180°
place on counterTop
stair coldWater
execute function putPlate

function putPlate:
lift plate
position plate over kitchenSink
lay gently in kitchenSink
execute function scrubPlate

function scrubPlate:
get sponge
with Sponge:
dip in soapyWater
stroke over plateSurfaces
place on counterTop
execute function rinsePlate

function rinsePlate:
open wasteWater drain
when wasteWater = 0:
cover wasteWater drain
turn coldWater tap to ,,on"
if kitchenSink = 50%full:
turn coldWater tap ,,off"
move plate in coldWater
If plateSurfaces = clean:
place on counterTop
finish

1 comment:

  1. Nice. Here you can see the power of functions. Each function executes a certain subtask, and functions combined execute the whole task. It is more organized and easier to find pieces of code if you ever have to change something. But be aware of identation: when you are defining a function, all code within this function should be indented, showing the are only executed when that function is called.

    ReplyDelete