]> git.scottworley.com Git - slidingtile/commitdiff
Promote Board to a class so it can have methods.
authorScott Worley <scottworley@scottworley.com>
Thu, 31 Dec 2015 08:14:02 +0000 (00:14 -0800)
committerScott Worley <scottworley@scottworley.com>
Thu, 31 Dec 2015 08:14:02 +0000 (00:14 -0800)
sliding_tile_lib.cc
sliding_tile_lib.h
sliding_tile_lib_test.cc

index a4d522e6745a99507612540f9664ed3ab6f9a8ee..24642f1480cdc78c671afa16f3436c350e9b6164 100644 (file)
@@ -33,7 +33,7 @@ std::istream& operator>>(std::istream& is, Board& board) {
     }
     int numeric;
     is >> numeric;
     }
     int numeric;
     is >> numeric;
-    board[i] = numeric;
+    board.board[i] = numeric;
   }
   return is;
 }
   }
   return is;
 }
index 8967324fb745eba07d8cd98743edac3ae597757b..1ffe6fa24c3deaf33f1a4f475ff9eff0e8e26ca3 100644 (file)
@@ -6,7 +6,9 @@
 const int BOARD_DIM = 4;
 const int BOARD_SIZE = BOARD_DIM * BOARD_DIM;
 
 const int BOARD_DIM = 4;
 const int BOARD_SIZE = BOARD_DIM * BOARD_DIM;
 
-typedef signed char Board[BOARD_SIZE];
+struct Board {
+  signed char board[BOARD_SIZE];
+};
 std::istream& operator>>(std::istream& is, Board& board);
 
 extern signed char adjacent[BOARD_SIZE][5];
 std::istream& operator>>(std::istream& is, Board& board);
 
 extern signed char adjacent[BOARD_SIZE][5];
index 0bbaec3a85a4e89e31026684a4756a778ee42618..a0a6b52b01f97903359ee26120021a5c2b50e413 100644 (file)
@@ -39,7 +39,7 @@ TEST(Board, GoodInput) {
   is >> b;
   EXPECT_FALSE(is.fail());
   EXPECT_TRUE(is.eof());
   is >> b;
   EXPECT_FALSE(is.fail());
   EXPECT_TRUE(is.eof());
-  EXPECT_THAT(b, testing::ElementsAreArray({15,14,9,13,3,1,12,8,0,11,6,4,7,5,2,10}));
+  EXPECT_THAT(b.board, testing::ElementsAreArray({15,14,9,13,3,1,12,8,0,11,6,4,7,5,2,10}));
 }
 
 TEST(Board, ShortInput) {
 }
 
 TEST(Board, ShortInput) {