-
Notifications
You must be signed in to change notification settings - Fork 0
/
carboard.c
executable file
·76 lines (59 loc) · 1.76 KB
/
carboard.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "carboard.h"
int main() {
showMenu();
return EXIT_SUCCESS;
}
/*MAIN MENU
* Displays main menu choices*/
void showMenu() {
Cell board[BOARD_HEIGHT][BOARD_WIDTH];
while (TRUE) {
int choice;
printf("\n");
printf("Welcome to Car Board \n");
printf("-------------------- \n");
printf("1. Play game \n");
printf("2. Show student's information \n");
printf("3. Quit \n\n");
choice = validateNumber();
if (choice == 1) {
showCommands();
initialiseBoard(board);
displayBoard(board, NULL);
printf("load <g>\n");
printf("quit\n\n");
initialiseGame();
}
if (choice == 2) {
showStudentInformation();
}
if (choice == 3) {
printf("\n");
printf("Good Bye!\n\n");
break;
}
}
}
/*Displays commands */
void showCommands(){
printf("\n");
printf("You can use the following commands to play the game: \n");
printf("load <g> \n");
printf("\t g: number of the game board to load \n");
printf("init <x>,<y>,<direction> \n");
printf("\t x: horizontal position of the car on the board (between 0 & 9) \n");
printf("\t y: vertical position of the car on the board (between 0 & 9) \n");
printf("\t direction: direction of the car's movement (north, east, south, west) \n");
printf("forward (or f) \n");
printf("turn_left (or 1) \n");
printf("turn_right (or r) \n");
printf("quit \n\n");
}
/*Displays student information*/
void showStudentInformation()
{
printf("\n");
printf("Name: %s \n",STUDENT_NAME);
printf("No: %s \n",STUDENT_ID);
printf("Email: %s \n\n",STUDENT_EMAIL);
}