// // Assignment 2 21T3 COMP1511: CS Pizzeria // pizzeria.c // // This program was written by YOUR-NAME-HERE (z5555555) // on INSERT-DATE-HERE // // TODO: INSERT-DESCRIPTION-HERE // // Version 1.0.0: Release #include #include #include // TODO: add any extra #includes your code needs here. #include "pizzeria.h" // TODO: add your own #defines here. struct ingredient { // TODO: add your own fields in Stage 2. struct ingredient *next; }; struct order { // TODO: add your own fields in Stage 1. // Looking to store a price field? Try putting in "double price;" here! struct order *next; }; struct pizzeria { // TODO: add your own fields if required. struct order *orders; }; // TODO: add any other structs you define here. ////////////////////////////////////////////////////////////////////// // TODO: add prototypes for any helper functions you create here. // Prints a single order void print_order( int num, char *customer, char *pizza_name, double price, int time_allowed ); // Prints an ingredient given the name, amount and price in the required format. // This will be needed for stage 2. void print_ingredient(char *name, int amount, double price); //////////////////////////////////////////////////////////////////////// // Stage 1 Functions // //////////////////////////////////////////////////////////////////////// struct pizzeria *create_pizzeria() { // Allocates memory to store a `struct pizzeria` and returns a pointer to // it. The variable `new` holds this pointer! struct pizzeria *new = malloc(sizeof(struct pizzeria)); new->orders = NULL; // TODO: this function has already been implemented for the current // struct pizzeria. When you decide to change struct pizzeria, change // this function as well. return new; } int add_order( struct pizzeria *pizzeria, char *customer, char *pizza_name, double price, int time_allowed ) { // TODO: fill in the rest of this function return SUCCESS; } void print_all_orders(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function // Do not change this part of the function print_selected_order(pizzeria); return; } int next_deadline(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return 0; } //////////////////////////////////////////////////////////////////////// // Stage 2 Functions // //////////////////////////////////////////////////////////////////////// void select_next_order(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return; } void select_previous_order(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return; } void print_selected_order(struct pizzeria *pizzeria) { // TODO: Change this once you have implemented the selected order // functionality. printf("\nNo selected order.\n"); } int add_ingredient( struct pizzeria *pizzeria, char *ingredient_name, int amount, double price ) { // TODO: fill in the rest of this function return SUCCESS; } double calculate_total_profit(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return 0.0; } //////////////////////////////////////////////////////////////////////// // Stage 3 Functions // //////////////////////////////////////////////////////////////////////// int cancel_order(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return SUCCESS; } void free_pizzeria(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return; } int refill_stock( struct pizzeria *pizzeria, char *ingredient_name, int amount, double price ) { // TODO: fill in the rest of this function return SUCCESS; } void print_stock(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return; } int can_complete_order(struct pizzeria *pizzeria) { // TODO: fill in the rest of this function return SUCCESS; } //////////////////////////////////////////////////////////////////////// // Stage 4 Functions // //////////////////////////////////////////////////////////////////////// int complete_order(struct pizzeria *pizzeria) { return SUCCESS; } int save_ingredients(struct pizzeria *pizzeria, char *file_name) { return SUCCESS; } int load_ingredients(struct pizzeria *pizzeria, char *file_name) { return SUCCESS; } //////////////////////////////////////////////////////////////////////// // HELPER FUNCTIONS - Add your own here // //////////////////////////////////////////////////////////////////////// // Prints a single order // // `print_order` will be given the parameters: // - `num` -- the integer that represents which order it is sequentially. // - `customer` -- the name of the customer for that order. // - `pizza_name` -- the pizza the customer ordered. // - `price` -- the price the customer is paying for the pizza. // - `time_allowed` -- the time the customer will wait for the order. // // `print_order` assumes all parameters are valid. // // `print_order` returns nothing. // // This will be needed for Stage 1. void print_order( int num, char *customer, char *pizza_name, double price, int time_allowed ) { printf("%02d: %s ordered a %s pizza ($%.2lf) due in %d minutes.\n", num, customer, pizza_name, price, time_allowed); return; } // Prints a single ingredient // // `print_ingredient` will be given the parameters: // - `name` -- the string which contains the ingredient's name. // - `amount` -- how many of the ingredient we either need or have. // - `price` -- the price the ingredient costs. // // `print_ingredient` assumes all parameters are valid. // // `print_ingredient` returns nothing. // // This will be needed for Stage 2. void print_ingredient(char *name, int amount, double price) { printf(" %s: %d @ $%.2lf\n", name, amount, price); }