//*************************************************************** // // title: RoomCleaningSimulation // author: © Ed C. Epp - all rights reserved // date: 4-20-99 // // Pick up the laundry and leave the room. // //*************************************************************** import java.applet.Applet; public class RoomCleaningSimulation extends Applet { Room edsRoom; Butler james; public void init () { edsRoom = new Room("sort.room", this); james = new Butler (11,2, edsRoom); edsRoom.waitForStart(); james.forward(); james.turnRight(); james.pickUp(); james.forward(1); james.turnLeft(); while(james.getY()<7) doRow(); } public void doRow() { int counter = 0; while(james.isFrontClear()) { james.forward(); if (james.isFrontClothes()) { counter = counter+1; loadClothes(); } } while (counter>0) { james.backward(); dumpClothes(); counter = counter-1; } while (james.getX()<10) james.backward(); james.turnLeft(); james.forward(); james.turnRight(); } public void loadClothes() { james.turnLeft(2); james.putDown(); james.turnLeft(2); james.pickUp(); james.turnLeft(2); james.putIn(); james.pickUp(); james.turnLeft(2); } public void dumpClothes() { james.turnLeft(2); james.putDown(); james.takeOut(); james.turnLeft(2); james.putDown(); james.turnLeft(2); james.pickUp(); james.turnLeft(2); } public void move() { while(james.isFrontClear()) { james.forward(); } } }