#include "md.h"

 

 

/*******************************************************************************/

/*                                                                             */

/* process for one order                                                       */

/*                                                                             */

/*******************************************************************************/

void process(int item_code, int number, int *no1, int *no2, int *no3)

{

             if ((item_code == REG_HAM_CODE) && (*no1 + number >= 0)) {

                           *no1 = *no1 + number;

             }

             else if ((item_code == DBL_HAM_CODE) && (*no2 + number >= 0)) {

                           *no2 = *no2 + number;

             }

             else if ((item_code == COKE_CODE) && (*no3 + number >= 0)) {

                           *no3 = *no3 + number;

             }

             else {

                           printf("\n Error --- Check the code or number !!\n");

             }

}

 

 

/*******************************************************************************/

/*                                                                             */

/* process for one customer                                                    */

/*                                                                             */

/*******************************************************************************/

int input_process(int *no1, int *no2, int *no3, int *prog_cont)

{

             int          flag = 1;               /* flag for scanf */

             int          processing =1;   /* 1 for processing, 0 for end of processing */

             int          item_code;                       /* for menu item code */

             int          number;                           /* the number of item */

 

 

             printf("\n Enter the item code (EOF for quit) : ");

             flag = scanf("%d", &item_code);

 

             if (flag == 1) {

                           if ((item_code > 0) && (item_code < MAX_ITEM + 1)) {

                                        printf(" Enter the number : ");

                                        flag = scanf("%d", &number);

 

                                        if (flag == 1) {

                                                   process(item_code, number, no1, no2, no3);

                                        }

                                        else {

                                                   *prog_cont = 0;

                                                     processing = 0;

                                        }

                           }

                           else if (item_code == 0) {

                                        processing = 0;

                           }

                           else {

                                        printf("\n Error --- Check the item code !!\n");

                           }

             }

             else {

                           *prog_cont = 0;

                           processing = 0;

             }

 

             return(processing);

}

 

/*******************************************************************************/

/*                                                                             */

/* process for daily record                                                    */

/*                                                                             */

/*******************************************************************************/

void total_process(int no1, int no2, int no3, int *tno1, int *tno2, int *tno3)

{

    *tno1 = *tno1 + no1;

    *tno2 = *tno2 + no2;

    *tno3 = *tno3 + no3;

}