Source code de Car park ticket machine:

Source code de Car park ticket machine: - Programmation

Marsh Posté le 19-01-2002 à 00:10:55    

->> Salut a tous <<-
 
Voila le code:
 
#include <stdio.h>
#include <conio.h>
#include <string.h>
 
//*****************************************************************************
//                          HNC SOFTWARE INGINEERING                          Ý
//                     CAR PARK TICKET MACHINE PROTOTYPE                      Ý
// Nimo                        ASSIGNMENT No2                  DUE: 08/01/02  Ý
//*****************************************************************************
 
void main ()    //The main program start here
{
 int price1, price3, price8; // New prices after set-up by Attendant
 int dp1=80, dp3=190, dp8=400; // Default prices
 char letter; // Pre-definned keys
 int sum=0;   // Value set to 0
 int hour;
 int start;  // Used for the goto command
 char att;   // Special key press for the attendant
 char c,quit='n';  //Initialise to continue
 int verif;  // Password verification
 _setcursortype(_NOCURSOR);  // To hide the cursor in the windows
 textbackground(4);  //Set-up the background as red
 clrscr();   // to clear the screen
 price1=dp1;       // define initialising the prices
 price3=dp3;
 price8=dp8;
 
 do                   // Loop: do{ ... while{ ...
 {
  //The top window or banner seting
 window(10,2,70,3);
 textbackground(9);
 textcolor(6);
 clrscr();
 gotoxy(10,1);
 cprintf("          CAR PARK TICKET MACHINE\r\n" );
 
 window(19,9,61,18);   //Back window to use it as a Shadow
 textbackground(7);
 textcolor(4);
 clrscr();
 gotoxy(15,5);
 cprintf("Nimo" );  // This will be hiden because of the main window
 
 window(20,10,60,17);     //The Waiting window
 textbackground(8);
 textcolor(14);
 clrscr();
 gotoxy(15,0);
 cprintf("\r\n\n\n" );
 cprintf("----------- Waiting for user ! ---------- \r\n" );
 scanf("%c",&att);
 if (att=='c';)       // Special key press to enter the Attendant menu
 {
  clrscr();
  cprintf(" Please enter your verification password \r\n" );
  scanf("%i",&verif);
  if (verif==1234)     // Check the password
  {
   clrscr();    // Window for the old prices for the tickets
   cprintf("Wellcome to the car park Attendant Menu \r\n" );
   cprintf("Set-up ticket prices: \r\n\n" );
   cprintf("1 Hour ticket old price: %i \r\n",price1);
   cprintf("3 Hour ticket old price: %i \r\n",price3);
   cprintf("8 Hour ticket old price: %i \r\n",price3);
   cprintf("All price are in pences \r\n" );
   getch();   // Wait for any key press
 
   clrscr();
   cprintf("Enter new prices for the ticket by order \r\n " );
   gotoxy(1,3);
   cprintf("For 1 Hour Tickets \r\n" );
   scanf("%i",&price1);    // Storing the new Price in price1
   gotoxy(1,5);
   cprintf("For 3 Hours Tickets \r\n" );
   scanf("%i",&price3);    // Storing the new Price in price3
   gotoxy(1,7);
   cprintf("For 8 Hours Tickets \r\n" );
   scanf("%i",&price8);    // Storing the new Price in price8
 
   clrscr();   // clearing the screen and showing the New prices
   cprintf(" ------- NEW TICKET PRICES SETUP ------- \r\n\n" );
   cprintf("    New 1 Hour ticket price: %i \r\n\n",price1);
   cprintf("    New 3 Hour ticket price: %i \r\n\n",price3);
   cprintf("    New 8 Hour ticket price: %i \r\n",price8);
   getch();
  }
 }
 
 if (verif==1234)  // If the password is correct then the New price will take effect
 {
  dp1=price1;
  dp3=price3;
  dp8=price8;
 }
 window(19,9,61,18);   //Back window like shadow
 textbackground(7);
 textcolor(4);
 clrscr();
 gotoxy(15,5);
 cprintf("Nimo" );
 
 window(20,10,60,17);     //wellcome window
 textbackground(8);
 textcolor(14);
 clrscr();
 gotoxy(15,0);
 cprintf("\r\n" );
 cprintf("Welcome to the car park ticket machine ! \r\n" );
 cprintf("To check the price per hour press any key \r\n" );
 getch(); // wellcome message finish
 clrscr();
 
 //The top window or banner
 window(10,2,70,3);
 textbackground(9);
 textcolor(6);
 clrscr();
 gotoxy(10,1);
 cprintf("CAR PARK TICKET MACHINE by FloppySoft Ltd \r\n" );
 
 //The shadow window
 textbackground(4);
 window(19,9,61,18);
 textbackground(7);
 textcolor(4);
 clrscr();
 gotoxy(15,5);
 cprintf("Nimo" );
 
 
 start:      // Loop start here by the goto command
 sum=0;      // Initialiase sum to 0
 window(20,10,60,17);  //Price window for user
 textbackground(8);
 textcolor(14);
 clrscr();
 gotoxy(10,0);
 cprintf(" \r\n" );
 cprintf("Ticket price for 1 Hour parking.....%i \r\n",dp1);
 cprintf("Ticket price for 3 Hours parking....%i \r\n",dp3);
 cprintf("Ticket price for 8 Hours parking....%i \r\n\n",dp8);
 cprintf("--- Please choose your parking hour --- \r\n" );
 printf("              Hour: " );
 scanf("%i",&hour);  // Store the input in the value hour
 if (hour==1)  // 1 hour
 {
  do               // Loop: do{ ... }while
  { clrscr();
  cprintf("      You have chosen 1 Hour parking \r\n" );
  cprintf("----------------------------------------- \r" );
  cprintf(" Please insert: %i \r\n",dp1);
  cprintf(" (Amount in Pences) \r\n" );
  cprintf(" Press any of these key on keyboard: \r\n\n" );
  cprintf("   - t=10p - F=50 p - P=?1 - T=?2 - \r\n" );
  letter=getch();
  clrscr();
  if (letter=='t';) //Key press t
  {
   gotoxy(10,0);
   sum=sum+10; // Add 10 into the value sum
   cprintf("The money you have to pay is %i",price1-sum);
 
   getch();
   clrscr();
  }
  if (letter=='F';)  //Key press on F
  {
   gotoxy(10,0);
   sum=sum+50;  // Add 50 into the value sum
 
   cprintf("The money you have to pay is %i",price1-sum);
   getch();
   clrscr();
  }
  if (letter=='P';) //Key press on P
  {
   gotoxy(10,0);
   sum=sum+100;  // Add 100 into the value sum
 
   cprintf("The money you have to pay is %i",price1-sum);
   getch();
   clrscr();
  }
  if (letter=='T';) //Key press on T
  {
   gotoxy(10,0);
   sum=sum+200; // Add 200 into the value sum
   cprintf("The money you have to pay is %i \r\n",price1-sum);
   gotoxy(12,0);
 
   getch();
   clrscr();
  }
  }while(sum!=price1); // Loop condition
 
  gotoxy(10,0);  // ticket issued design
  cprintf("      Ticket Issued....Press any key. \r\n" );
  getch();
  clrscr();
  gotoxy(10,0);
  cprintf("\r\n" );
  cprintf("         I-----------------------I\r\n" );
  gotoxy(11,0);
  cprintf("         I      You Got:         I\r\n" );
  gotoxy(12,0);
  cprintf("         I       1 Hour          I\r\n" );
  gotoxy(13,0);
  cprintf("         I       Ticket          I\r\n" );
  gotoxy(14,0);
  cprintf("         I_______________________I\r\n" );
  getch();
  clrscr();
  cprintf("\r\n" );
  cprintf("        If you wish to quit press Y\r\n\n\n" );  // Option quit ot continue
  cprintf("        To continue press any key \r\n" );
  quit=getch(); // waiting for an input to do the action ( quit or continue )
 
 }
 
 else // Other option
  if (hour==3)   // 3 hours
  {
  do
  {
   clrscr();
   cprintf("      You have chosen 3 Hours parking \r\n" );
   cprintf("----------------------------------------- \r" );
   cprintf(" Please insert: %i \r\n",dp3);
   cprintf(" (Amount in Pences) \r\n" );
   cprintf(" Press any of these key on keyboard: \r\n\n" );
   cprintf("   - t=10p - F=50 p - P=?1 - T=?2 - \r\n" );
   letter=getch();
   clrscr();
   if (letter=='t';)
   {
    gotoxy(10,0);
    sum=sum+10;
    cprintf("The money you have to pay is %i",price3-sum);
 
    getch();
    clrscr();
   }
   if (letter=='F';)
   {
    gotoxy(10,0);
    sum=sum+50;
 
    cprintf("The money you have to pay is %i",price3-sum);
    getch();
    clrscr();
   }
   if (letter=='P';)
   {
    gotoxy(10,0);
    sum=sum+100;
 
    cprintf("The money you have to pay is %i",price3-sum);
    getch();
    clrscr();
   }
   if (letter=='T';)
   {
    gotoxy(10,0);
    sum=sum+200;
    cprintf("The money you have to pay is %i \r\n",price3-sum);
    gotoxy(12,0);
 //   refound=sum-price1;
 //   cprintf("You refound is %i:\r\n",refound);
    getch();
    clrscr();
   }
  }while(sum!=price3);
 
  gotoxy(10,0);
  cprintf("      Ticket Issued....Press any key. \r\n" );
  getch();
  clrscr();
  gotoxy(10,0);
  cprintf("\r\n" );
  cprintf("         I-----------------------I\r\n" );
  gotoxy(11,0);
  cprintf("         I       You Got:        I\r\n" );
  gotoxy(12,0);
  cprintf("         I       3 Hours         I\r\n" );
  gotoxy(13,0);
  cprintf("         I        Ticket         I\r\n" );
  gotoxy(14,0);
  cprintf("         I_______________________I\r\n" );
  getch();
  clrscr();
  cprintf("\r\n" );
  cprintf("        If you wish to quit press Y\r\n\n\n" );
  cprintf("        To continue press any key \r\n" );
  quit=getch();
 
  }
   else
 
   if (hour==8)
    {
    do
    {
     clrscr();
     cprintf("      You have chosen 8 Hours parking \r\n" );
     cprintf("----------------------------------------- \r" );
     cprintf(" Please insert: %i \r\n",dp8);
     cprintf(" (Amount in Pences) \r\n" );
     cprintf(" Press any of these key on keyboard: \r\n\n" );
     cprintf("   - t=10p - F=50 p - P=?1 - T=?2 - \r\n" );
     letter=getch();
     clrscr();
    if (letter=='t';)
    {
     gotoxy(10,0);
     sum=sum+10;
     cprintf("The money you have to pay is %i",price8-sum);
 
     getch();
     clrscr();
    }
    if (letter=='F';)
     {
     gotoxy(10,0);
     sum=sum+50;
 
     cprintf("The money you have to pay is %i",price8-sum);
     getch();
     clrscr();
    }
    if (letter=='P';)
    {
     gotoxy(10,0);
     sum=sum+100;
 
     cprintf("The money you have to pay is %i",price8-sum);
     getch();
     clrscr();
    }
    if (letter=='T';)
    {
     gotoxy(10,0);
     sum=sum+200;
     cprintf("The money you have to pay is %i \r\n",price8-sum);
     gotoxy(12,0);
  //   refound=sum-price1;
  //   cprintf("You refound is %i:\r\n",refound);
     getch();
     clrscr();
    }
  }while(sum!=price8);
 
  gotoxy(10,0);
  cprintf("      Ticket Issued....Press any key. \r\n" );
  getch();
  clrscr();
  gotoxy(10,0);
  cprintf("\r\n" );
  cprintf("         I-----------------------I\r\n" );
  gotoxy(11,0);
  cprintf("         I      You Got:         I\r\n" );
  gotoxy(12,0);
  cprintf("         I       8 Hours         I\r\n" );
  gotoxy(13,0);
  cprintf("         I       Ticket          I\r\n" );
  gotoxy(14,0);
  cprintf("         I_______________________I\r\n" );
  getch();
  clrscr();
  cprintf("\r\n" );
  cprintf("        If you wish to quit press Y\r\n\n\n" );
  cprintf("        To continue press any key \r\n" );
  quit=getch();
 
   }
     else  // When the user entered an incorrect input or key press
     {
      clrscr();
      textbackground(4);
      cprintf("\r\n\n" );
      cprintf("You have entered an Incorrect Price plan \r\n" );
      cprintf("........Press any key to continue....... \r\n" );
      getch();
      goto start;  // loop by the command Goto and the anchor start:
     }
 }while(quit!='y';); // if Y press the program will stop
 getch();  //waiting for key press
}  // End of the program
//--------------------------------------------------------------------------
//This Car Park Ticket Machine was made using Turbo C++                     Ý
//Prototype version 4.4                                                     Ý
//Coded and design by Nimo for the Company FloppySoft 2002                  Ý             Ý
//--------------------------------------------------------------------------
 
 
 
Merci de bien vouloir me crediter au cas ou vous l'utiliser
 
Nimo and Nimo_Corp

 

[edtdd]--Message édité par Nimo--[/edtdd]

Reply

Marsh Posté le 19-01-2002 à 00:10:55   

Reply

Marsh Posté le 19-01-2002 à 01:18:55    

cool.
 
tu pourrais indenter qu'on comprenne ?
 
sinon ça fait le café aussi ?

Reply

Marsh Posté le 19-01-2002 à 01:22:01    

jamais on t'as appris à faire des fonctions ?
tiens spécial dédicace :D : http://www.ioccc.org/

Reply

Marsh Posté le 19-01-2002 à 01:22:50    

enfin je suis méchant, on devine ce que ça fait.

Reply

Marsh Posté le 19-01-2002 à 03:32:22    

->> hahah <<-
 
C pas mal ca!
 
c la premier fois que je code en c donc j'ai fais ce que je pouvai, oui les fonctions je connais mais bon c trop facile avec
 
Aller amuse toi bien a decomposer si tu veux  
 
Nimo

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed