void displaySplashScreen(void) { /* printf("%s", APP_TITLE); */ stdclrscr(); printlnProjectName(); pressAnyKeyToContinue(); }
int main() { cout<<"Welcome to console Chess!"; cout<<endl<<"Enter 00 any time to exit the game."; cout<<endl<<"Enter 0 to continue without loading the saved game: "; if (getche() != '0') { loadGame(); } pressAnyKeyToContinue(); while(turn != 0) { print(); cout<<endl<<endl<<endl<<endl<<endl<<"Move from: "; xi = getch(); yi = getch(); if (xi == '0' && yi == '0') { cout<<endl<<"Enter 0 to exit without saving the game: "; if (getche() != '0') { saveGame(); } pressAnyKeyToContinue(); exit(0); } else if (prepareIntial() == 0) { pressAnyKeyToContinue(); continue; } cout<<endl<<"Move to: "; xf = getch(); yf = getch(); if (prepareFinal() == 0) { pressAnyKeyToContinue(); continue; } proceed(); } return 0; }
void proceed() { prepare(); if (isMoveValid() == 1) { if (cf == 'k') { remove("save.dat"); cout<<endl<<"Player "<<turn<<" has won!"; pressAnyKeyToContinue(); turn = 0; return; } if (ci == 'P' && turn == 1 ? yf == 7 : yf == 0) { Game[xf][yf] = turn == 1 ? 'Q' : -'Q'; } else { Game[xf][yf] = turn == 1 ? ci : -ci; } Game[xi][yi] = ' '; turn = turn == 1 ? 2 : 1; } else { pressAnyKeyToContinue(); } }
void scanPhoneBookEntry(phoneBookEntry* entry) { printlnInfoMessage("Please input valid values to avoid errors."); printlnInfoMessage("An enter key is considered as a blank input."); println("[FULL NAME ENTRY]"); printf("Firstname>> "); getline(entry->firstName); printf("Lastname>> "); getline(entry->lastName); printf("Middle Initial>> "); getline(entry->mInitial); println("\n[CONTACT NUMBER]"); printlnInfoMessage("Format: DDDDDDDDDDD"); printlnInfoMessage("Invalid input characters are non-digit value."); printlnInfoMessage("It will be marked as 'X' when displaying a phoneBookEntry."); printf("Personal No.>> "); getline(entry->mobileNumber); pressAnyKeyToContinue(); }
int main(void) { phoneBook simpon; char input = '\0'; initPhoneBook(&simpon); displaySplashScreen(); /** This is the other way of saying, int isPlaying = 1; */ boolean isPlaying = True; while (isPlaying) { stdclrscr(); printlnProjectName(); nnewline(2); println("+--------------------------------------------------+"); print("|"); printlnInfoMessage("The input is not case-sentitive. |"); print("|"); printlnInfoMessage("(e.g.: 'A' and 'a' is the same thing.) |"); print("|"); printlnInfoMessage("The boxed character is the user key input. |"); print("|"); printlnInfoMessage("(i.e.: [A]dd, 'A' is the user key input.) |"); println("+--------------------------------------------------+"); newline(); printlnPhoneBookMenu(); nnewline(2); print("What would like to do? "); input = getchar(); /* scanf("%c", &input); */ /* If the user will not input a value, * then bring the user to the main menu again. */ if (input == '\n') { continue; } stdclrscr(); /* char upperChar = toupper(input); * if (upperChar == MNUQUIT) { * // do something * } else if (upperChar == MNUVIEW) { * // do something * } // ... * else { * // do something * } * * */ switch(toupper(input)) { case MNUQUIT: { isPlaying = False; displayByeScreen(); break; } case MNUVIEW: { printlnPhoneBook(simpon); break; } case MNUMODI: { printf("TODO: Modify..."); break; } case MNUDELE: { /* deleteContactEntry(&simpon); */ printf("TODO: Delete..."); break; } case MNUFIND: { printf("TODO: Find..."); break; } case MNUADDE: { addContactEntry(&simpon); break; } case MNUHACK: { hackSimpon(&simpon); break; } default: { char msg[MAXSTR]; char chrStr[MAXCHR]; /* initialize strings before using them */ initString(msg); initString(chrStr); /* * printf("INFO: Unknown input => %c", input); */ strcat(msg, "Unknown input => "); chrToStr(input, chrStr); strcat(msg, chrStr); printlnInfoMessage(msg); break; } } newline(); pressAnyKeyToContinue(); getchar(); } newline(); return 0; }