Browse Source

minor fixes

remotes/origin/David
David Moeller 11 months ago
parent
commit
ad8fc5d7bc
  1. 8
      src/main/c/Minesweeper/minesweeper_start.c
  2. 2
      src/main/c/Minesweeper/minesweeper_start.h
  3. 4
      test/Minesweeper/test_bomb_in_array.c

8
src/main/c/Minesweeper/minesweeper_start.c

@ -22,7 +22,6 @@ void game_minesweeper();
void options_minesweeper(); void options_minesweeper();
Minesweeper_Board initialize_minesweeper(); Minesweeper_Board initialize_minesweeper();
void place_bombs(Minesweeper_Board *board); void place_bombs(Minesweeper_Board *board);
bool bomb_in_array(int *array, int bomb, int length);
bool array_contains_value(int *array, int value, int length); bool array_contains_value(int *array, int value, int length);
void draw_minesweeper(Minesweeper_Board *board); void draw_minesweeper(Minesweeper_Board *board);
int open_tile(Minesweeper_Board *board, int tile); int open_tile(Minesweeper_Board *board, int tile);
@ -182,13 +181,6 @@ void place_bombs(Minesweeper_Board *board){
} }
} }
bool bomb_in_array(int *array, int value, int length){
for(int i = 0; i < length; i++){
if(array[i] == value){return true;}
}
return false;
}
bool array_contains_value(int *array, int value, int length){ bool array_contains_value(int *array, int value, int length){
for(int i = 0; i < length; i++){ for(int i = 0; i < length; i++){
if(array[i] == value){return true;} if(array[i] == value){return true;}

2
src/main/c/Minesweeper/minesweeper_start.h

@ -13,7 +13,7 @@ typedef struct Minesweeper_Board{
void minesweeper_start(); void minesweeper_start();
Minesweeper_Board initialize_minesweeper(); Minesweeper_Board initialize_minesweeper();
bool bomb_in_array(int *array, int bomb, int length);
bool array_contains_value(int *array, int bomb, int length);
int number_of_bombs(Minesweeper_Board *board, int tile); int number_of_bombs(Minesweeper_Board *board, int tile);

4
test/Minesweeper/test_bomb_in_array.c

@ -16,7 +16,7 @@ void test_bomb_in_array(void){
int length = 10; int length = 10;
/* act */ /* act */
result = bomb_in_array(array, bomb, length);
result = array_contains_value(array, bomb, length);
/* assert */ /* assert */
TEST_ASSERT_TRUE(result); TEST_ASSERT_TRUE(result);
@ -31,7 +31,7 @@ void test_bomb_not_in_array(void){
int length = 10; int length = 10;
/* act */ /* act */
result = bomb_in_array(array, bomb, length);
result = array_contains_value(array, bomb, length);
/* assert */ /* assert */
TEST_ASSERT_FALSE(result); TEST_ASSERT_FALSE(result);

Loading…
Cancel
Save