Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Carlos Garcia
- Lesson 4 Evaluation 1
- Math with beepers
- */
- package Lesson4;
- import kareltherobot.World;
- public class Evaluation1 extends EsperBot {
- public Evaluation1(int street, int avenue, Direction direction, int beeperCount) {
- super(street, avenue, direction, beeperCount);
- }
- public static void main(String[] args) {
- World.setDelay(5);
- World.setVisible();
- World.setSize(10, 10);
- World.showSpeedControl(true);
- World.readWorld("Lesson4World5.kwld");
- Evaluation1 zgod1 = new Evaluation1(1, 1, East, 0);
- Evaluation1 zgod2 = new Evaluation1(2, 1, East, 0);
- Evaluation1 zgod3 = new Evaluation1(3, 1, East, 0);
- Evaluation1 zgod4 = new Evaluation1(4, 1, East, 0);
- zgod1.add();
- zgod2.add();
- zgod3.add();
- zgod4.add();
- }
- /**
- * Makes the additions
- * @return void
- * */
- public void add(){
- for (int i = 0; i < 2; i++) { //loop to pick the beepers in the two parts of the addition
- move();
- while (nextToABeeper()) {
- pickBeeper();
- }
- }
- move();
- while (anyBeepersInBeeperBag()) { //places the sum of the beepers in the equal sign
- putBeeper();
- }
- move();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement