Advertisement
GARC923

L4E1

Oct 21st, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. /**
  2. Carlos Garcia
  3. Lesson 4 Evaluation 1
  4. Math with beepers
  5. */
  6.  
  7. package Lesson4;
  8.  
  9. import kareltherobot.World;
  10.  
  11.  
  12. public class Evaluation1 extends EsperBot {
  13.     public Evaluation1(int street, int avenue, Direction direction, int beeperCount) {
  14.         super(street, avenue, direction, beeperCount);
  15.     }
  16.  
  17.  
  18.     public static void main(String[] args) {
  19.         World.setDelay(5);
  20.         World.setVisible();
  21.         World.setSize(10, 10);
  22.         World.showSpeedControl(true);
  23.         World.readWorld("Lesson4World5.kwld");
  24.  
  25.         Evaluation1 zgod1 = new Evaluation1(1, 1, East, 0);
  26.         Evaluation1 zgod2 = new Evaluation1(2, 1, East, 0);
  27.         Evaluation1 zgod3 = new Evaluation1(3, 1, East, 0);
  28.         Evaluation1 zgod4 = new Evaluation1(4, 1, East, 0);
  29.  
  30.         zgod1.add();
  31.         zgod2.add();
  32.         zgod3.add();
  33.         zgod4.add();
  34.  
  35.     }
  36.  
  37.     /**
  38.      * Makes the additions
  39.      * @return void
  40.      * */
  41.     public void add(){
  42.         for (int i = 0; i < 2; i++) { //loop to pick the beepers in the two parts of the addition
  43.             move();
  44.             while (nextToABeeper()) {
  45.                 pickBeeper();
  46.             }
  47.         }
  48.         move();
  49.         while (anyBeepersInBeeperBag()) { //places the sum of the beepers in the equal sign
  50.             putBeeper();
  51.         }
  52.         move();
  53.     }
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement