TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JERRY COFFIN
from: KURT KUZBA
date: 1997-09-04 05:17:00
subject: MATHPLAY.CPP kk3.0 3/3

/*   MATHPLAY.CPP   PUBLIC DOMAIN   version kk3.0   3/3   */
int menu(void)
{
   static int iPlay, iSelect = 0;
   char *ppszChoices[] = {
      "Addition", "Subtraction", "Multiplication", "Division", "Quit"
   };
   char *ppszHotkeys[] = {
      " A -> ", " S -> ", " M -> ", " D -> ", " Q -> "
   };
   window(1, 1, 80, 25);
   textattr(0x20);
   clrscr();
   window(20, 8, 60, 18);
   textattr(0x5f);
   clrscr();
   cputs("  Would you like to practice your Math?");
   window(22, 9, 58, 17);
   textattr(0x1f);
   clrscr();
   window(23, 10, 57, 16);
   for(iPlay = 0; iPlay < 5; iPlay++)
   {
      gotoxy(1, iPlay + 1);
      cprintf("%s", ppszHotkeys[iPlay]);
   }
   do   {
      for(iPlay = 0; iPlay < 5; iPlay++)
      {
         textattr((iPlay == iSelect) ? 0x71 : 0x1f);
         gotoxy(7, iPlay + 1);
         cprintf(" %-20s", ppszChoices[iPlay]);
      }
      switch(iPlay = (0 == (iPlay = getch()) ? -getch() : iPlay))
      {
         case 'A': case 'a':
            iPlay = 0; iSelect = 0; break;
         case 'S': case 's':
            iPlay = 0; iSelect = 1; break;
         case 'M': case 'm':
            iPlay = 0; iSelect = 2; break;
         case 'D': case 'd':
            iPlay = 0; iSelect = 3; break;
         case 'Q': case 'q': case 27:
            iPlay = 0; iSelect = 4; break;
         case  13:
            iPlay = 0; break;
         case -72: case '8':
            iSelect = (iSelect + 4) % 5; break;
         case -80: case '2': case ' ':
            iSelect = (iSelect + 1) % 5; break;
      }
   }   while(iPlay);
   switch(iSelect)
   {
      case 0: Addition *Add = new Addition;
         Add->Play(); delete Add; break;
      case 1: Subtraction *Sub = new Subtraction;
         Sub->Play(); delete Sub; break;
      case 2: Multiplication *Mult = new Multiplication;
         Mult->Play(); delete Mult; break;
      case 3: Division *Div = new Division;
         Div->Play(); delete Div; break;
      case 4:   textattr(11); window(1, 1, 80, 25); clrscr();
         gotoxy(30, 12);   cputs("Thank you for playing!\n\r");
         iPlay++; break;
   }
   return !iPlay;
}
int main(void)
{
   while(menu())
   ;
   return 0;
}
/*   end   MATHPLAY.CPP   3/3   */
> ] It's around somewhere. I put it where I wouldn't lose it....
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.