예제 #1
0
 public void move(Cat cat)
 {
     Position pos = cat.getPosition();
     pos.x += dir[0];
     pos.y += dir[1];
     cat.setPosition(pos);
 }
예제 #2
0
 private static void runGame(CellObject[][] board)
 {
     Cat cat = new Cat();
     while (true) {
         cat.move();
         if (!inBounds(cat, board)) break;
         Position p = cat.getPosition();
         board[p.y][p.x].apply(cat);
     }
     Console.ReadLine();
 }
예제 #3
0
 private static bool inBounds(Cat cat, CellObject[][] board)
 {
     Position p = cat.getPosition();
     if (p.y < 0 || p.y > board.Length-1 || p.x < 0 || p.x > board[0].Length-1) return false;
     return true;
 }