Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. package tests;
  2.  
  3. import model.*;
  4.  
  5. import java.util.ArrayList;
  6.  
  7. public class TestBots {
  8.     public static void main(String[] args) {
  9.  
  10.         ArrayList<Entity> entities=new ArrayList<>();
  11.         //(Location loc, int id, Directions dir, int moveSpeed)
  12.         entities.add(new FlexibleBot(new Location(1,1), 1234, Movable.Directions.UP,Movable.FAST_SPEED));
  13.         entities.add(new FlexibleBot(new Location(2,2), 4321, Movable.Directions.LEFT,Movable.SLOW_SPEED));
  14.  
  15.         Map m=new Map(entities);
  16.         m.printMap();
  17.         FlexibleBot f=(FlexibleBot) m.removeBotFromMap(((FlexibleBot) entities.get(0)));
  18.         f.move(m);
  19.         m.putBotOnMap(f);
  20.         m.printMap();
  21.  
  22.         ((FlexibleBot)entities.get(1)).move(m);
  23.         m.updateMap();
  24.         m.printMap();
  25.     }
  26. }
  27.  
  28. package tests;
  29.  
  30. import model.*;
  31.  
  32. public class TestPolyInterface {
  33.     public static void main(String[] args) {
  34.  
  35.     }
  36.  
  37.     public static boolean testFlexMove(FlexibleBot flex, Map m){
  38.         return flex.move(m);
  39.     }
  40.  
  41.     public static void testSpeedUp(Movable mover, Map m, int speedUpFactor){
  42.         m.printMap();
  43.         moveMovables(mover, m);
  44.         m.printMap();
  45.         Movable.speedUpByValue((Entity)mover, speedUpFactor);
  46.         moveMovables(mover, m);
  47.         m.printMap();
  48.     }
  49.  
  50.     public static boolean moveMovables(Movable move, Map map){
  51.         boolean moved=false;
  52.  
  53.         map.removeBotFromMap((Bot)move);
  54.         moved=move.move(map);
  55.         map.putBotOnMap((Bot)move);
  56.  
  57.         return moved;
  58.     }
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement