示例#1
0
 @Test
 public void addBumpersTest() {
   model.addSquareBumper(0, 0, 0, "sBump");
   model.addCircularBumper(0, 20, 0, "cBump");
   model.addTriangularBumper(0, 40, 0, "tBump");
   assertFalse(model.getBumper("sBump") == null);
   assertTrue(model.getBumper("") == null);
   assertTrue(model.getBumper("sBump") instanceof SquareBumper);
   assertTrue(model.getBumper("cBump") instanceof CircularBumper);
   assertTrue(model.getBumper("tBump") instanceof TriangularBumper);
   model.addSquareBumper(0, 0, 0, "sBump");
   model.addCircularBumper(0, 20, 0, "cBump");
   model.addTriangularBumper(0, 40, 0, "tBump");
   assertTrue(model.getBumpers().size() == 3);
 }
示例#2
0
 @Override
 public void mouseClicked(MouseEvent mouseEvent) {
   Board b = bgui.getGridView();
   if (b.getAction() == Board.Action.ADD && bgui.getSelectedComponent().equals("Gizmo")) {
     String gizmoShape = bgui.getGizmoShape();
     Point mouseP = MouseInfo.getPointerInfo().getLocation();
     Point gridP = b.getLocationOnScreen();
     int x = mouseP.x - gridP.x;
     int y = mouseP.y - gridP.y;
     boolean added = false;
     switch (gizmoShape) {
       case "Circle":
         added = m.addCircularBumper(x, y, 0, "circle");
         break;
       case "Triangle":
         added = m.addTriangularBumper(x, y, 0, "triangle");
         break;
       case "Square":
         added = m.addSquareBumper(x, y, 0, "square");
         break;
       case "Teleporter":
         added = m.addTeleporterBumper(x, y, 0, "teleporter");
         break;
       default:
     }
     if (added) {
       bgui.setMessageColor(Color.GREEN);
       bgui.setMessage(gizmoShape + " added!");
     } else {
       bgui.setMessageColor(Color.RED);
       bgui.setMessage("That space is occupied, " + gizmoShape + " cannot be added");
     }
   }
 }
示例#3
0
 @Test
 public void clearTest() {
   model.addSquareBumper(0, 0, 0, "sBump");
   model.addCircularBumper(0, 20, 0, "cBump");
   model.addTriangularBumper(0, 40, 0, "tBump");
   model.clear();
   assertTrue(model.getBumper("sBump") == null);
   assertTrue(model.getBumper("cBump") == null);
   assertTrue(model.getBumper("tBump") == null);
   assertTrue(model.getBumpers().size() == 0);
 }
示例#4
0
 @Test
 public void occupiedSpacesTest() {
   boolean[][] occupied = model.getOccupiedSpaces();
   for (int i = 0; i < occupied.length; i++) {
     for (int j = 0; j < occupied[i].length; j++) {
       assertFalse(occupied[i][j]);
     }
   }
   model.addCircularBumper(0, 0, 0, "cBump");
   assertTrue(model.getOccupiedSpaces()[0][0]);
 }