First Run this program
Quote:
SuperMarket sm = new SuperMarket("Sainsburys"
ArrayList basket = new ArrayList();
basket.add(sm.buy("250g all-purpose flour");
basket.add(sm.buy("1 tsp baking soda");
basket.add(sm.buy("1/4 tsp salt");
basket.add(sm.buy("200g butter");
basket.add(sm.buy("165g brown sugar");
basket.add(sm.buy("100g white sugar");
basket.add(sm.buy("1 tsp vanilla extract");
basket.add(sm.buy("1 egg");
basket.add(sm.buy("100g chocolate chips");
Quote:
// Preheat oven for ten minutes.
Oven oven = Oven.getInstance();
oven.setTemperature(175);
try {
Thread.sleep(600000); // 10 minutes.
}
catch (InterruptedException e) {
System.out.println("No cookies today"
;
}
Quote:
Cupboard cupboard = Cupboard.getInstance();
cupboard.open();
Collection bowl = cupboard.get("bowl"
cupboard.close();
Iterator it = basket.iterator();
while (it.hasNext()) {
Ingredient ingredient = (Ingredient) it.next();
if (ingredient == null) {
throw new RuntimeException("Duh, you forgot an ingredient!"
}
bowl.add(ingredient);
Collections.shuffle(bowl);
}
Quote:
cupboard.open();
Collection tinFoil = cupboard.get("greased tin foil"
Collection tray = cupboard.get("baking tray"
cupboard.close();
tray.add(tinFoil);
for (int i = 0; i < 9; i++) {
tinFoil.add(new Cookie(bowl));
}
Quote:
// Stick the tray in the oven for at least 10 minutes.
oven.open();
oven.add(tray);
oven.close();
try{
Thread.sleep(600000); // 10 minutes.
}
catch (InterruptedException e) {
System.out.println("Schtop! These cookies are not ready yet!"
}
Quote:
// Check on the progress of the cookies every minute.
boolean stillWaiting = true;
while (stillWaiting) {
try {
Thread.sleep(60000); // One minute.
}
catch (InterruptedException e) {
System.out.println("Stop interrupting me!"
}
// Check that all the cookies are cooked!
stillWaiting = false;
for (int i = 0; i < tinFoil.size(); i++) {
Cookie cookie = (Cookie) tinFoil.get(i);
if (!cookie.isCooked()) {
stillWaiting = true;
break;
}
}
}
// Take the tray out.
oven.open();
tray = (Collection) oven.remove(oven.indexOf(tray));
oven.close();
// Bug fix suggested by Tim Bishop.
// (We forgot to turn off the oven!)
oven.turnOff();
// Wait for things to cool down.
try {
tray.wait(300000); // 5 minutes.
}
catch (InterruptedException e) {
System.out.println("Ouch! Burnt fingers!"
}
Quote:
it = tray.iterator();
while (it.hasNext()) {
Cookie cookie = (Cookie) it.next();
cookie.eat();
}
Advertise Contact Us Privacy Policy and Terms of Usage FAQ Canadian Desi © 2001 Marg eSolutions Site designed, developed and maintained by Marg eSolutions Inc. |