Tell us what part of your algorithm could be converted to on
Tell us what part of your algorithm could be converted to one or custom methods.
Enter bathroom
Turn on light
Go to sink
Open Cabinet
Locate Toothpaste and toothbrush
Brush teeth
Turn on faucet
Rinse mouth
Spit out water
Clean toothbrush
Put toothbrush and toothpaste back into cabinet
Close cabinet
Go to door
Turn off light
Close door
Solution
Turn can be converted to custom method which will take what to turn(light/faucet) and it\'s state(on/off). Turn on functionality is used multiple times across the process.
Eg: Turn on light, and Turn on faucet
Go to can also be converted to custom method since it is being used multiple times
Eg: Go to sink, Go to door
Close functionality. Eg: Close door, Close cabinet. What needs to be closed can be passed an an argument to Close.
