Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int /* 0 is 7pm, 1 is 9pm */ tables[3][2] = {{0,0},{0,0},{0,0}}, /* 1 = half, 2 = full, 3 = B&B */ board[4] = {1, 1, 1 ,1};
- char *tablenames[3] = {"Endor","Naboo","Tatooine"}, *dinnertimes[2] = {"7pm", "9pm"};
- void dinnerbooking()
- {
- int ID, i, x, timechoice;
- char tablechoice[20];
- do{
- printf("What is your Booking ID?: ");
- fflush(stdin);
- scanf("%d",&ID);
- } while(!(ID >= 0 && ID <= 3));
- if (board[ID] == 1 || board[ID] == 2){
- printf("Current tables available:\n");
- for (i=0;i<3;i++){
- for (x=0;x<2;x++){
- if (tables[i][x] == 0){
- printf("%s at %s\n",tablenames[i], dinnertimes[x]);
- }
- }
- }
- do {
- char input[100];
- printf("Enter the table and time you would like to book: ");
- fflush(stdin);
- gets(input);
- sscanf(input,"%s %d",tablechoice,&timechoice);
- } while (!(!strcmp(tablechoice,tablenames[0]) || !strcmp(tablechoice,tablenames[1]) || !strcmp(tablechoice,tablenames[2])) && (timechoice != 7 || timechoice != 9));
- switch(tablechoice[0]){
- case 'E':
- tables[0][(timechoice == 9)] = 1;
- break;
- case 'N':
- tables[1][(timechoice == 9)] = 1;
- break;
- case 'T':
- tables[2][(timechoice == 9)] = 1;
- break;
- }
- printf("Your seat is booked :)");
- }
- else {
- printf("You can't book a dinner.");
- return;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement