Hey guys just like to ask a question how i could use the variable drinkType
to access either hot or cold drinks depending on what they choose in the menu selection.
To choose 1 or 2 the same function will run but i need it to just execute
a certain part if they where to choose hot for example. If they choose cold i would need to run only the statements that print the cold and not the hot.
Both options have to call the same function though
Iv written a do while in my main to choose either
1 Hot Drinks Summary
2 Cold Drinks Summary
if they press 1 or 2 it suppose to run the function below and print out
Code:
/****************************************************************************
* Menu option #1: Display Summary
* Allows the user to display a summary of all hot or cold drink categories
* and items.
****************************************************************************/
void displaySummary(GJCType* menu, char drinkType)
{
/* CategoryTypePtr currentCat;
ItemType currentItem;
assert(menu != NULL);
currentCat = menu->headCategory;
while(currentCat !=NULL)
{
currentCat= currentCat->nextCategory;
}
print the summary of the list*/
}
Code:
#ifndef GJC_H
#define GJC_H
/* System-wide header files. */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
/* System-wide constants. */
#define ID_LEN 5
#define MIN_NAME_LEN 1
#define MAX_NAME_LEN 25
#define MIN_DESC_LEN 1
#define MAX_DESC_LEN 250
#define NUM_PRICES 3
#define HOT 'H'
#define COLD 'C'
#define ERRORCODE 1
#define BUFFER_SIZE 800
#define NC_ARRAY_SIZE 500
#define TRUE 1
#define FALSE 0
typedef struct category* CategoryTypePtr;
typedef struct item* ItemTypePtr;
/* Structure definitions. */
typedef struct price
{
unsigned dollars;
unsigned cents;
} PriceType;
typedef struct item
{
char itemID[ID_LEN + 1];
char itemName[MAX_NAME_LEN + 1];
PriceType prices[NUM_PRICES];
char itemDescription[MAX_DESC_LEN];
ItemTypePtr nextItem;
} ItemType;
typedef struct category
{
char categoryID[ID_LEN + 1];
char categoryName[MAX_NAME_LEN + 1];
char drinkType; /* (H)ot or (C)old. */
char categoryDescription[MAX_DESC_LEN];
CategoryTypePtr nextCategory;
ItemTypePtr headItem;
unsigned numItems;
} drinkType;
typedef struct gjc
{
CategoryTypePtr headCategory;
unsigned numCategories;
} GJCType;
int commandLineArguments(int argc, char *argv[]);
#endif