version: 0.0 last updated: 2025-07-18 09:00

Assignment 2 - CS Eats

Overview

Welcome to CS Eats 📋 👩‍🍳 🍔 🚗 🍽️ 😋 💰

With the dominance of online ordering and fast-paced food delivery, restaurants are seeking efficient solutions to manage customers, orders, and deliveries. Your task is to implement CS Eats, a comprehensive food delivery management system.

This assignment will test your ability to create, use, manipulate, and solve problems using linked lists. You will represent customers, orders, and a delivery driver using linked lists within a central restaurant structure.

COMP1911 Students

If you are a COMP1911 student, you will be assessed on your performance in up to and including Stage 3.3 ONLY for this assignment, which will make up the performance component of your grade. Style will be marked as usual and will make up the remaining 20% of the marks for this assignment. You are not required to attempt Stages 3.4 and beyond. You may attempt the later stages if you wish, but you will not be awarded any marks for work beyond Stage 3.3.

COMP1511 Students

If you are a COMP1511 student, you will be assessed on your performance in Stages 1, 2, 3, and 4, which will make up the performance component of your grade. Style will be marked as usual and will make up the remaining 20% of the marks for this assignment.

Getting Started

There are a few steps to getting started with CS Eats.

  1. Create a new folder for your assignment work and move into it.
mkdir ass2
cd ass2
  1. Use this command on your CSE account to copy the file into your current directory:
1511 fetch-activity cs_eats
  1. Run 1511 autotest cs_eats to make sure you have correctly downloaded the file.
1511 autotest cs_eats
  1. Read through this introduction and Stage 1.

  2. Spend a few minutes playing with the reference solution.

 1511 cs_eats
  1. Think about your solution, draw some diagrams to help you get started.

  2. Start coding!

Assignment Structure & Starter Code

This assignment utilises a multi-file system. There are three files we use in CS Eats:

  • Main File (main.c): This file contains the main function, which serves as an entry point for the program. It is responsible for printing a welcome banner, setting the restaurant's name, creating the restaurant, and initiating a command loop so users can interact with the app.

A main() function has been provided in main.c to get you started.

int main(void) {
    // Welcome banner
    print_welcome_banner();

    // Restaurant setup
    printf("Enter a restaurant name: ");
    char name[MAX_SIZE];
    scan_name(name);
    struct restaurant *restaurant = create_restaurant(name);

    printf("\n");

    // Command loop
    command_loop(restaurant);

    // End message
    printf("Goodbye!\n");

    return 0;
}

Printing a Welcome Banner

The first statement in main() calls the provided print_welcome_banner() function to print a welcome banner:

void print_welcome_banner(void) {
    printf(
        "Welcome to CS Eats!\n"
        "    _____           )   ________        ___       \n"
        "   (     )      )  (___/___     \\  __  |\" \"|  __  \n"
        "    |   |     _(__/_)_     \\S   | |''| |'\" | |\"\"| \n"
        "    |___|    /        \\S   |TS  | | \"| |''\"| |'\"| \n"
        "    :^_^:    |   CS   |TS  |____| |\"'| |\" \"| |\" | \n"
        "   _`~^~'_   |  EATS  |____| __   ---------------\n"
        " /    ^    \\ |________|   .-'--`--. - - - - - - -\n"
        " ~[$|$|$|$]~              '-O---O-' -------------\n\n"
    );
}

Scanning the Restaurant Name

In this section, the program receives input from the user for the restaurant's name:

It declares name, a character array of size MAX_SIZE to store the restaurant's name.

It then uses the provided scan_name() function, which reads user input and stores it in the name array.

printf("Enter a restaurant name: ");
char name[MAX_SIZE];
scan_name(name);

Creating the Restaurant

Next, the program creates the restaurant itself. It:

  • Declares a pointer restaurant to a struct restaurant.
  • Calls create_restaurant(), passing the restaurant's name as an argument.
  • Stores the pointer returned by create_restaurant() in restaurant.

struct restaurant *restaurant = create_restaurant(name);

The create_restaurant() function is currently incomplete. You will need to implement this in Stage 1.1. It is responsible for setting up the initial state of the restaurant, including allocating memory and setting default values.

Starting the Command Loop

After creating the restaurant, the program starts a command loop by calling the command_loop() function which you will need to implement in Stage 1.2. This function allows users to interact with the app to add or remove customers; or add, remove, cook, deliver and eat orders; and more.

command_loop(restaurant);

Exiting the Program

The last statement in main() prints a goodbye message:

printf("Goodbye!\n");

  • Header File (cs_eats.h): This file declares constants, enums, structs, and function prototypes for the program. You will need to add prototypes for any functions you create in this file. You should also add any of your own constants and/or enums to this file.

  • Implementation File (cs_eats.c): This file is where most of the assignment work will be done, as you will implement the logic and functionality required by the assignment here. This file also contains stubs of Stage 1 functions for you to implement. It does not contain a main function, so you will need to compile it alongside main.c. You will need to define any additional functions you may need for later stages in this file.

The implementation file cs_eats.c contains some "Provided Function Definitions" to help simplify some stages of this assignment. These functions have been implemented and should not need to be modified to complete this assignment.

These provided functions will be explained in the relevant stages of this assignment. Please read the function comments and the specification as we will suggest certain provided functions for you to use.

We have defined some structs in cs_eats.h to get you started. You may add fields to any of the structs if you wish.

The Restaurant

struct restaurant {
    char name[MAX_SIZE];
    int profit;
    struct customer *customers;
    struct order *orders;
};

Purpose: To store all the information about the restaurant. It contains:

  • The name of the restaurant.
  • The restaurant's profit ($).
  • A list of customers who can place and receive orders.
  • A list of orders placed by customers.

Customers

struct customer {
    char name[MAX_SIZE];
    int balance;
    int distance;
    struct order *orders;
    struct customer *next;
};

Purpose: To represent a customer of the restaurant. It contains:

  • The customer's name.
  • The amount of money the customer has remaining ($).
  • The distance from the customer to the restaurant (km).
  • A pointer to a list of orders delivered to the customer.
  • A pointer to the next customer in the customer list.

Orders

struct order {
    char customer_name[MAX_SIZE];
    enum order_flavour flavour;
    enum order_protein protein;
    enum order_base base;
    int id;
    enum order_status status;
    struct order *next;
};

Purpose: To represent an order placed at the restaurant. It contains:

  • The name of the customer the order is for.
  • The order's food item:
    • A flavour (e.g., Chilli, Garlic, Lemon, Sesame, or None).
    • A protein (e.g., Chicken, Beef, Lamb, Tofu, or Veggie).
    • A base (e.g., Curry, Noodles, Salad, Soup, or Wrap).
  • A unique identification number for the order.
  • The current status of the order (e.g., Pending, Ready, En Route, or Delivered).
  • A pointer to the next order in the order list.

The following enum definitions are provided for you in cs_eats.h. You can create your own enums if you would like, but you should not need to modify the provided enums.

Order Status

enum order_status { PENDING, READY, EN_ROUTE, DELIVERED };
Purpose: To represent the current status of an order.


Order Flavour

enum order_flavour {
    CHILLI,
    GARLIC,
    LEMON,
    SESAME,
    NONE,
    INVALID_FLAVOUR
};
Purpose: To represent the optional flavour added to an order's food item.


Order Protein

enum order_protein {
    CHICKEN,
    BEEF,
    LAMB,
    TOFU,
    VEGGIE,
    INVALID_PROTEIN
};
Purpose: To represent the type of protein used in an order's food item.


Order Base

enum order_base {
    CURRY,
    NOODLES,
    SALAD,
    SOUP,
    WRAP,
    INVALID_BASE
};
Purpose: To represent the base dish of an order's food item.

Reference Implementation

To help you understand the expected behaviour of CS Eats, we have provided a reference implementation. If you have any questions about the behaviour of your assignment, you can compare its output to the reference implementation.

To run the reference implementation, use the following command:

 1511 cs_eats

Input:

UNSW
?
q

Input and Output:

1511 cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: ?
*********************[     Usage Info     ]*********************
  a c [name] [balance] [distance]                               
    Add a customer to the head of the customer list             
  a o [customer] [flavour] [protein] [base]                     
    Append an order for a customer                              
  a d [driver_name]                                             
    Add a driver                                                
  i c [name] [balance] [distance] [position]                    
    Insert a customer at [position]                             
  p                                                             
    Print the restaurant, including customers and orders        
  c [n]                                                         
    Cook up to [n] PENDING orders                               
  d [order_id]                                                  
    Deliver a READY order                                       
  x o [order_id]                                                
    Cancel a PENDING order and refund the customer              
  x c [name]                                                    
    Remove customer [name]                                      
  e [name] [position] [amount]                                  
    Customer eats [amount] delivered orders from [position]     
  m [name] [distance]                                           
    Merge customers within [distance] from [name] into [name]   
  s                                                             
    Sort customers by distance                                  
  t                                                             
    Simulate one driver turn                                    
  q                                                             
    Quit the program, freeing all memory                        
  ?                                                             
    Show this help information                                  
****************************************************************

Enter command: q
Goodbye!

Allowed C Features

This assignment must be implemented exclusively using linked lists for all core data structures and logic.

Other than arrays, there are no restrictions on C features in this assignment, except for those outlined in the Style Guide. If you choose to use features beyond what has been taught in COMP1511/1911, be aware that course staff may not be able to assist you.

FAQ

Q: Can I edit the provided code?

Yes! Feel free to modify, replace, or discard any of the provided code.

For example: you may wish to add fields to the provided struct restaurant definition.

You are also encouraged to create your own constants, enums, structs, and helper functions.

Q: What C features can I use?

For everything not taught in the course, check the Style Guide:

  • If the guide says "avoid", it may incur a style mark penalty if not used correctly.
  • If the guide says "illegal" or "do not use", it will result in a style mark penalty (see the Style Marking Rubric).

These rules exist to ensure that everyone develops the required foundational knowledge and to maintain a level playing field for all students.

Q: Can I use arrays?

A: No, you cannot use arrays in any part of this assignment. The only exception is when using strings. Using arrays for any part of this assignment will result in a performance mark of zero.

Stages

The assignment has been divided into incremental stages.

Stage 1

  • Stage 1.1 - Creating and Initialising Structs.
  • Stage 1.2 - Command Loop.
  • Stage 1.3 - Add Customers.
  • Stage 1.4 - Print the Restaurant.
  • Stage 1.5 - Handle Errors.

Stage 2

  • Stage 2.1 - Insert Customers.
  • Stage 2.2 - Add Orders.
  • Stage 2.3 - Loyalty Discount.
  • Stage 2.4 - Cook Orders.
  • Stage 2.5 - Deliver Orders.

Stage 3

  • Stage 3.1 - Close Restaurant.
  • Stage 3.2 - Cancel Orders.
  • Stage 3.3 - Remove Customers.
  • Stage 3.4 - Eat Food.
  • Stage 3.5 - Merge.

Stage 4

  • Stage 4.1 - Sort.
  • Stage 4.2 - Reorder.
  • Stage 4.3 - Driver.

Extension (not for marks)

  • SplashKit - Create and Share a Graphical User Interface.

Video Overview

A video explanation to help you get started with the assignment can here found here:

Your Tasks

This assignment consists of four stages. Each stage builds on the work of the previous stage, and each stage has a higher complexity than its predecessor. You should complete the stages in order.

Stage 1

The lights are on, the stoves are heating up, and the chef is putting on their big chef hat.

Stage 1 is where you turn your starter code into a restaurant that can greet customers and perform tasks, all whilst keeping the kitchen tidy.

This milestone has been divided into five substages:

  • Stage 1.1 - Creating and Initialising Structs.
  • Stage 1.2 - Command Loop.
  • Stage 1.3 - Adding Customers.
  • Stage 1.4 - Printing the Restaurant.
  • Stage 1.5 - Error Handling.

Stage 1.1 - Create and Initialise Structs

In this stage, you shape the core data structures so CS Eats is ready the moment the first customer arrives.

Your first task is to implement three functions:

  1. create_restaurant()
  2. create_customer()
  3. create_order()

Each of these functions takes in a list of parameters, and returns a pointer to a struct.

You will find unimplemented function stubs for these functions in cs_eats.c.

// Stage 1.1
// Function to create a restaurant
// Params:
//      name - the restaurant's name
// Returns: a pointer to the new restaurant
struct restaurant *create_restaurant(char name[MAX_SIZE]) {
    // TODO: Replace this with your code
    printf("create_restaurant() not yet implemented\n");
    return NULL;
}
// Stage 1.1
// Function to create a customer
// Params:
//      name     - the customer's name
//      balance  - the amount of money the customer starts with ($)
//      distance - the distance of the customer from the restaurant (km)
// Returns: a pointer to the new customer
struct customer *create_customer(
    char name[MAX_SIZE],
    int balance,
    int distance
) {
    // TODO: Replace this with your code
    printf("create_customer() not yet implemented\n");
    return NULL;
}
// Stage 1.1
// Function to create an order
// Params:
//      customer_name - the name of the customer who placed the order
//      flavour       - the order's selected flavour
//      protein       - the order's selected protein
//      base          - the order's selected base menu item
//      id            - the order's unique identification number
//      status        - the order's status
// Returns: a pointer to the new order
struct order *create_order(
    char customer_name[MAX_SIZE],
    enum order_flavour flavour,
    enum order_protein protein,
    enum order_base base,
    int id,
    enum order_status status
) {
    // TODO: Replace this with your code
    printf("create_order() not yet implemented\n");
    return NULL;
}

To implement these functions:

  1. Find the function stubs in cs_eats.c and read the provided comments.
  2. Malloc the space required for the struct.
  3. Assign the provided parameters to the struct's fields.
  4. Initialise all remaining struct fields to some reasonable values.
  5. Return a pointer to the newly-created struct.

Clarifications

  • No error handling is required for this stage.
  • The restaurant's initial profit is $0.

Testing

There are no autotests for Stage 1.1.

You will need to test your work by:

  1. Compiling your code with dcc to ensure there are no warnings or errors.
  2. Writing temporary testing code to confirm that your functions behave as expected.

You can copy the following testing code into your main() function in main.c.

#include <string.h>
#include <stdio.h>

#include "cs_eats.h"

int main(void) {
    // Create a restaurant
    char restaurant_name[MAX_SIZE];
    strcpy(restaurant_name, "UNSW");
    struct restaurant *restaurant = create_restaurant(restaurant_name);

    // Check if create_restaurant() has returned NULL
    if (restaurant == NULL) {
        printf("ERROR: create_restaurant() has returned NULL\n");
    }

    // Print restaurant details
    printf("Restaurant created:\n");
    printf("  Name: %s\n", restaurant->name);
    printf("  Profit: %d\n", restaurant->profit);
    if (restaurant->customers == NULL) {
        printf("  Customers: NULL\n");
    } else {
        printf("  Customers not set to NULL\n");
    }
    if (restaurant->orders == NULL) {
        printf("  Orders: NULL\n\n");
    } else {
        printf("  Orders not set to NULL\n\n");
    }

    // Create a customer
    char customer_name[MAX_SIZE];
    strcpy(customer_name, "Jake");
    struct customer *customer = create_customer(customer_name, 500, 7);

    // Check if create_customer() has returned NULL
    if (customer == NULL) {
        printf("ERROR: create_customer() has returned NULL\n");
    }

    // Print customer details
    printf("Customer created:\n");
    printf("  Name: %s\n", customer->name);
    printf("  Balance: $%d\n", customer->balance);
    printf("  Distance: %d km\n", customer->distance);
    if (customer->orders == NULL) {
        printf("  Orders: NULL\n");
    } else {
        printf("  Orders not set to NULL\n");
    }
    if (customer->next == NULL) {
        printf("  Next Customer: NULL\n\n");
    } else {
        printf("  Next Customer not set to NULL\n\n");
    }

    // Create an order
    struct order *order = create_order(
        customer_name,
        LEMON,
        CHICKEN,
        NOODLES,
        42,
        PENDING
    );

    // Check if create_order() has returned NULL
    if (order == NULL) {
        printf("ERROR: create_order() has returned NULL\n");
    }

    // Print order details
    printf("Order created:\n");
    printf("  Customer Name: %s\n", order->customer_name);
    printf("  Flavour: %s\n", order_flavour_to_string(order->flavour));
    printf("  Protein: %s\n", order_protein_to_string(order->protein));
    printf("  Base: %s\n", order_base_to_string(order->base));
    printf("  ID: %d\n", order->id);
    printf("  Status: %s\n", order_status_to_string(order->status));
    if (order->next == NULL) {
        printf("  Next Order: NULL\n\n");
    } else {
        printf("  Next Order not set to NULL\n\n");
    }

    return 0;
}

This code calls create_restaurant(), create_customer() and create_order(), then prints the values stored in the fields of the returned structs.

You can compile and run your program with the following command:

dcc cs_eats.c main.c -o cs_eats
./cs_eats

When you run it, it should print the following:

Restaurant created:
  Name: UNSW
  Profit: 0
  Customers: NULL
  Orders: NULL

Customer created:
  Name: Jake
  Balance: $500
  Distance: 7 km
  Orders: NULL
  Next Customer: NULL

Order created:
  Customer Name: Jake
  Flavour: Lemon
  Protein: Chicken
  Base: Noodles
  ID: 42
  Status: PENDING
  Next Order: NULL

Visually, this can be represented as below:

01_01

Stage 1.2 - Command Loop

In this stage, you teach CS Eats to listen for commands.

Your second task is to begin implementing the command_loop() function, which is called by the main() function in main.c after creating the restaurant.

A function stub has been provided in the cs_eats.c starter code.

// Stage 1.2
// Function to run the command loop
// Params:
//     restaurant - a pointer to the restaurant
// Returns: None
void command_loop(struct restaurant *restaurant) {
    // TODO: Replace this with your code
    printf("command_loop() not yet implemented\n");
}

When command_loop() is called, your program should:

  1. Print "Enter command: " to prompt the user to enter a command.
  2. Scan in a command.
  3. Execute the command.
  4. Repeat steps 1 to 3 until the user enters the q quit command.

When q is entered, the function should end and immediately return to the main() function. The program will then print the goodbye message, as included in the starter code in main.c and end.

The command loop will be extended with new commands as you progress through each stage of the assignment.

Command

The first command you will implement is the help command:

?

This command is described below.

Description

When the help command is entered, the program should call the print_help() function provided in the cs_eats.c starter code. This displays a list of information about all commands that will be implemented by the end of this assignment.

// Function to print help information
// '?' command
// Params: None
// Returns: None
// Usage:
// ```
//      print_help();
// ```
void print_help(void) {
    printf(
        "*********************[     Usage Info     ]*********************\n"
        "  a c [name] [balance] [distance]                               \n"
        "    Add a customer to the head of the customer list             \n"
        "  a o [customer] [flavour] [protein] [base]                     \n"
        "    Append an order for a customer                              \n"
        "  a d [driver_name]                                             \n"
        "    Add a driver                                                \n"
        "  i c [name] [balance] [distance] [position]                    \n"
        "    Insert a customer at [position]                             \n"
        "  p                                                             \n"
        "    Print the restaurant, including customers and orders        \n"
        "  c [n]                                                         \n"
        "    Cook up to [n] PENDING orders                               \n"
        "  d [order_id]                                                  \n"
        "    Deliver a READY order                                       \n"
        "  x o [order_id]                                                \n"
        "    Cancel a PENDING order and refund the customer              \n"
        "  x c [name]                                                    \n"
        "    Remove customer [name]                                      \n"
        "  e [name] [position] [amount]                                  \n"
        "    Customer eats [amount] delivered orders from [position]     \n"
        "  m [name] [distance]                                           \n"
        "    Merge customers within [distance] from [name] into [name]   \n"
        "  s                                                             \n"
        "    Sort customers by distance                                  \n"
        "  r [name] [n] [id_1] [id_2] ... [id_n]                         \n"
        "    Reorder past orders                                         \n"
        "  t                                                             \n"
        "    Simulate one driver turn                                    \n"
        "  f [n]                                                         \n"
        "    Fast forward simulation by 'n' driver turns                 \n"
        "  q                                                             \n"
        "    Quit the program, freeing all memory                        \n"
        "  ?                                                             \n"
        "    Show this help information                                  \n"
        "****************************************************************\n"
        "\n"
    );
}

When the help command finishes, the command loop should repeat steps 1 to 3 to handle user commands until a q quit command has been entered.

Errors

  • If an invalid command is entered, your program should print
    "ERROR: Invalid command\n"

Clarifications

You may assume that:

  • All commands begin with a single char, followed by additional arguments. The number of arguments will depend on each command.
  • Commands will always be given the correct number of arguments.
  • Commands will always be given arguments of the correct type.

Examples

Input:

UNSW
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: q
Goodbye!

Input:

UNSW
?
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: ?
*********************[     Usage Info     ]*********************
  a c [name] [balance] [distance]                               
    Add a customer to the head of the customer list             
  a o [customer] [flavour] [protein] [base]                     
    Append an order for a customer                              
  a d [driver_name]                                             
    Add a driver                                                
  i c [name] [balance] [distance] [position]                    
    Insert a customer at [position]                             
  p                                                             
    Print the restaurant, including customers and orders        
  c [n]                                                         
    Cook up to [n] PENDING orders                               
  d [order_id]                                                  
    Deliver a READY order                                       
  x o [order_id]                                                
    Cancel a PENDING order and refund the customer              
  x c [name]                                                    
    Remove customer [name]                                      
  e [name] [position] [amount]                                  
    Customer eats [amount] delivered orders from [position]     
  m [name] [distance]                                           
    Merge customers within [distance] from [name] into [name]   
  s                                                             
    Sort customers by distance                                  
  r [name] [n] [id_1] [id_2] ... [id_n]                         
    Reorder past orders                                         
  t                                                             
    Simulate one driver turn                                    
  f [n]                                                         
    Fast forward simulation by 'n' driver turns                 
  q                                                             
    Quit the program, freeing all memory                        
  ?                                                             
    Show this help information                                  
****************************************************************

Enter command: q
Goodbye!

Input:

UNSW
j
k
l
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: j
ERROR: Invalid command
Enter command: k
ERROR: Invalid command
Enter command: l
ERROR: Invalid command
Enter command: q
Goodbye!

Stage 1.3 - Add Customers

When CS Eats first runs, a new restaurant with empty customer and order lists is created as shown below:

01_03_struct_restaurant

We would like to start taking orders, but before this can happen, the restaurant will need some customers!

In this stage, you will start registering new customers into your restaurant system!

Command

The add customer command will be called as follows:

a c [name: string] [balance: int] [distance: int]

For example, the command:

a c Jake 100 11

would add a customer named Jake with a balance of $100 at a distance of 11 km from the restaurant.

Description

Your task is to complete the add_customer() function stub in cs_eats.c.

// Stage 1.3
// Function to add a customer to the restaurant
// Params:
//      restaurant - a pointer to the restaurant
// Returns: None
void add_customer(struct restaurant *restaurant) {
    // TODO: Replace this with your code
    printf("add_customer() not yet implemented\n");
}

When an add customer command is entered, your program should:

  • Scan the customer's details (name, balance, and distance).
  • Create a new customer.
  • Insert the customer at the head of the restaurant's customer list.
  • Print a message to confirm that the command was successful:
    "Customer '[name]' added\n"
    where [name] is the name of the new customer.

After adding one customer, the restaurant should look something like this:

01_03_add_one_customer

Any other customers added via this command will be inserted at the head of the list and look something like this:

01_03_add_multiple_customers

Examples

Input:

UNSW
a c Jake 100 11
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: q
Goodbye!

Clarifications

  • No error handling is required at this stage.
  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • [balance] and [distance] are integers.

Stage 1.4 - Printing the Restaurant

The chef enters their passcode and the screen lights up: today's profit, hungry names, and what should be sizzling.

In this stage, you will implement a function to display the restaurant.

Command

p

Description

When the print command is entered, your program should print the restaurant's:

  • Profit.
  • Customer List.
  • Order List (empty until Stage 2.2).

A function stub for print_restaurant() has been provided to assist you:

// Stage 1.4
// Function to print the restaurant
// Params:
//      restaurant - a pointer to the restaurant
// Returns: None
void print_restaurant(struct restaurant *restaurant) {
    // TODO: Replace this with your code
    printf("print_restaurant() not yet implemented\n");
}

A function print_customer() has been provided to correctly print a single customer:

// Function to print a customer's details (name, balance, distance)
// Params:
//      customer - a pointer to the customer to print
// Returns: None
// Usage:
// ```
//      print_customer_details(customer);
// ```
void print_customer(struct customer *customer) {
    printf(
        "  %s ($%d, %d km)\n", 
        customer->name, 
        customer->balance, 
        customer->distance
    );
}

Additionally, a helper function print_header() has been provided:

// Function to print a header
// Params:
//      name - the name of the restaurant
// Returns: None
// Usage:
// ```
//      print_header(name);
// ```
void print_header(char name[MAX_SIZE]) {
    printf("******************[ %s ]******************\n", name);
}

If the restaurant has no customers, then print_restaurant() should print
" (no customers)" in place of the customer list.

At this stage, the restaurant has no orders, so print_restaurant() should print
" (no orders)" in place of the order list.

Examples

Input:

UNSW
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Clarifications

  • The restaurant's initial profit is $0.
  • At this stage, the restaurant's order list is empty, so no orders need to be printed yet.

Stage 1.5 - Error Handling

"The great thing about CS Eats is that it doesn't let our customers enter invalid data. Our previous delivery system let customers enter whatever they wanted... we once had an order to deliver four billion pizzas to the moon!" - Restaurant Manager

In this stage, you will modify your add_customer() code from Stage 1.3 to add some restrictions.

Errors

When adding a customer, if any of the following conditions are met, the customer should not be added, and the corresponding error message should be printed out instead:

  • If a customer with the same name already exists, the following error should be printed:
    "ERROR: Customer '[name]' already exists\n"
  • If the balance is less than or equal to zero, the following error should be printed:
    "ERROR: Balance must be positive\n"
  • If the distance is less than or equal to zero, the following error should be printed:
    "ERROR: Distance must be positive\n"

If more than one error occurs, only the first error in the order specified above should be addressed by printing an error message.

Examples

Input:

UNSW
a c Jake 100 11
p
a c Jake 101 12
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: a c Jake 101 12
ERROR: Customer 'Jake' already exists
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 0 11
a c Jake -1 11
a c Jake -999 11
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 0 11
ERROR: Balance must be positive
Enter command: a c Jake -1 11
ERROR: Balance must be positive
Enter command: a c Jake -999 11
ERROR: Balance must be positive
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 0
a c Jake 100 -1
a c Jake 100 -999
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 0
ERROR: Distance must be positive
Enter command: a c Jake 100 -1
ERROR: Distance must be positive
Enter command: a c Jake 100 -999
ERROR: Distance must be positive
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
p
a c Jake -1 -1
p
a c Sofia 50 -1
a c Sofia -1 20
a c Sofia -1 -1
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: a c Jake -1 -1
ERROR: Customer 'Jake' already exists
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: a c Sofia 50 -1
ERROR: Distance must be positive
Enter command: a c Sofia -1 20
ERROR: Balance must be positive
Enter command: a c Sofia -1 -1
ERROR: Balance must be positive
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Clarifications

For this stage, and all future stages of the assignment:

  • If more than one error occurs, only the first error in the order specified above should be printed.
  • Customer name comparisons are case-sensitive. For example, "Jake" and "jake" are treated as two distinct customers.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_eats.c
1511 style cs_eats.h
1511 style main.c
1511 autotest-stage 01 cs_eats
give cs1511 ass2_cs_eats cs_eats.c cs_eats.h main.c

Stage 2

The city is reaching for their phones as the restaurant kicks into top gear.

Stage 2 implements the core functionality of CS Eats.

This milestone has been divided into five substages:

  • Stage 2.1 - Insert Customer.
  • Stage 2.2 - Add Orders.
  • Stage 2.3 - Loyalty Discount.
  • Stage 2.4 - Cook Orders.
  • Stage 2.5 - Deliver Orders.

Stage 2.1 - Insert Customer

Another hungry name appears on the chef's screen. Instead of throwing them at the head of the list, CS Eats nudges a few customers out of the way to make life easier for today's driver.

In Stage 1, every new customer was added at the head of the restaurant’s customer list. You will now allow customers to be inserted at any position in the list.

Command

i c [name: string] [balance: int] [distance: int] [position: int]

The insert customer command consists of "i c" followed by the customer's details and the customer's [position] in the customer list. For example, the command:

i c Jake 100 11 2

would insert a customer named Jake with a balance of $100 and distance of 11 km at position 2 in the customer list.

Description

When an insert customer command is entered, your program should create a new customer and insert them into the restaurant's customer list according to the following rules:

  • If position &lt;= 1
    then the new customer should be inserted at the head of the customer list.
  • If position == n
    then after insertion, the new customer should be the n-th customer in the customer list.
  • If position is greater than the number of customers in the customer list
    then the new customer should be inserted at the tail of the customer list.

After inserting a customer, print a message to confirm that the command was successful:
"Customer '[name]' added\n"
where [name] is the name of the new customer.

Inserting a new customer i c Ibby 50 30 2 should look something like this:

Before:

02_01_insert_customer_before

After:

02_01_insert_customer_after

Errors

When inserting a customer, if any of the following conditions are met then the customer should not be inserted, and the corresponding error message should be printed out instead:

  • If a customer with exactly the same name already exists, the following error should be printed:
    "ERROR: Customer '[name]' already exists\n"

  • If the balance is not positive, the following error should be printed:
    "ERROR: Balance must be positive\n"

  • If the distance is not positive, the following error should be printed:
    "ERROR: Distance must be positive\n"

Examples

Input:

UNSW
i c Jake 100 11 1
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: i c Jake 100 11 1
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
p
i c Jake 100 11 1
p
i c Sasha 100 13 0
p
i c Angela 100 9 -99
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Jake 100 11 1
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Sasha 100 13 0
Customer 'Sasha' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Sasha ($100, 13 km)
  Jake ($100, 11 km)
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Angela 100 9 -99
Customer 'Angela' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Angela ($100, 9 km)
  Sasha ($100, 13 km)
  Jake ($100, 11 km)
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
p
i c Jake 100 11 2
p
i c Sasha 100 13 3
p
i c Angela 100 9 3
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Jake 100 11 2
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Jake ($100, 11 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Sasha 100 13 3
Customer 'Sasha' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Jake ($100, 11 km)
  Sasha ($100, 13 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Angela 100 9 3
Customer 'Angela' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Jake ($100, 11 km)
  Angela ($100, 9 km)
  Sasha ($100, 13 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
p
i c Jake 100 11 4
p
i c Sasha 100 13 6
p
i c Angela 100 9 99
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: i c Jake 100 11 4
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: i c Sasha 100 13 6
Customer 'Sasha' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
  Jake ($100, 11 km)
  Sasha ($100, 13 km)
[ORDERS]
  (no orders)

Enter command: i c Angela 100 9 99
Customer 'Angela' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
  Jake ($100, 11 km)
  Sasha ($100, 13 km)
  Angela ($100, 9 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
p
i c Jake -1 -1 2
i c Sofia 50 -1 2
i c Sofia -1 20 2
i c Sofia -1 -1 2
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: i c Jake -1 -1 2
ERROR: Customer 'Jake' already exists
Enter command: i c Sofia 50 -1 2
ERROR: Distance must be positive
Enter command: i c Sofia -1 20 2
ERROR: Balance must be positive
Enter command: i c Sofia -1 -1 2
ERROR: Balance must be positive
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • [balance], [distance], and [position] are integers.
  • Positions are 1-indexed. That is, a node at the head of a list is in position 1.

Stage 2.2 - Add Order

Across town, a customer finalises their cart, hits "Pay", and sees a confirmation tick appear. A moment later the same order ID glows on the chef's screen.

With the customer list organised, you can now create orders, calculate prices and fees, as well as update both customer balances and restaurant profit

Command

a o [name: string] [flavour: string] [protein: string] [base: string]

The add order command consists of "a o" followed by the [name] of the customer placing the order and the details of the order. For example, the command:

a o Jake LEMON CHICKEN NOODLES

would add an order for Jake for Lemon Chicken Noodles.

Description

When an add order command is entered, your program should:

  1. Scan:

    • The customer's name with the provided scan_name() function.
    • The order's flavour with the provided scan_flavour() function.
    • The order's protein with the provided scan_protein() function.
    • The order's base with the provided scan_base() function.
  2. Create a new order for the scanned food item with a PENDING status. Give each order a new [id] number:

    • The first order should have an [id] of 1.
    • The second order should have an [id] of 2.
    • The n-th order should have an [id] of n.
  3. Update the restaurant finances:

    • Add the item price (described below) to the restaurant's profit.
    • Subtract the item price and delivery fee (described below) from the customer's balance.
  4. Append the order to the tail of the restaurant's order list.

  5. Print a message to confirm that the command was successful:
    "Order '#[id]' added: $[item_price] item + $[delivery_fee] delivery\n"
    where:
    [id] is the unique identification number of the order.
    [item_price] is the price of the food item being ordered.
    [delivery_fee] is the order's delivery fee.

To scan the flavour, protein, and base of the new customer, use the provided scan_flavour(), scan_protein(), and scan_base() functions included in the starter code:

// Scans a string and converts it to an order_flavour.
//
// Params: None
// Returns:
//      The corresponding order_flavour enum, if the string was valid,
//      Otherwise, returns INVALID_FLAVOUR.
//
// Usage:
// ```
//      enum order_flavour flavour = scan_flavour();
// ```
enum order_flavour scan_flavour(void) {
    char type[MAX_SIZE];
    scan_token(type, MAX_SIZE);
    return string_to_order_flavour(type);
}

// Scans a string and converts it to an order_protein.
//
// Params: None
// Returns:
//      The corresponding order_protein enum, if the string was valid,
//      Otherwise, returns INVALID_PROTEIN.
//
// Usage:
// ```
//      enum order_protein protein = scan_protein();
// ```
enum order_protein scan_protein(void) {
    char type[MAX_SIZE];
    scan_token(type, MAX_SIZE);
    return string_to_order_protein(type);
}

// Scans a string and converts it to an order_base.
//
// Params: None
// Returns:
//      The corresponding order_base enum, if the string was valid,
//      Otherwise, returns INVALID_BASE.
//
// Usage:
// ```
//      enum order_base base = scan_base();
// ```
enum order_base scan_base(void) {
    char type[MAX_SIZE];
    scan_token(type, MAX_SIZE);
    return string_to_order_base(type);
}

The price of an item is the sum of its flavour price + protein price + base price.

Flavour Price

The flavour price depends on which flavour was ordered. The price of:

  • A NONE flavour is $0.
  • Any other flavour is $1.
Protein Price

The protein price depends on which protein was ordered. The price of:

  • CHICKEN is $2.
  • BEEF is $4.
  • LAMB is $6.
  • TOFU is $2.
  • VEGGIE is $0.
Base Price

The base price depends on which base was ordered. The price of:

  • CURRY is $16.
  • NOODLES is $14.
  • SALAD is $12.
  • SOUP is $10.
  • WRAP is $14.

Customers within 10 km (inclusive) of the restaurant are charged:

  • A flat-rate fee of $5.

Customers further than 10 km from the restaurant are charged:

  • A flat-rate fee of $5.
  • PLUS a distance surcharge of $1 for every kilometre beyond the 10 km flat-rate distance.

// Function to print a single order
// Params:
//      order - a pointer to the order to print
// Returns: None
// Usage:
// ```
//      print_order(order);
// ```
void print_order(struct order *order) {
    printf("    ß%s :: ", order_status_to_string(order->status));
    printf("#%d ", order->id);
    if (order->flavour != NONE) {
        printf("%s ", order_flavour_to_string(order->flavour));
    }
    printf(
        "%s %s",
        order_protein_to_string(order->protein),
        order_base_to_string(order->base)
    );
    printf(" :: %s", order->customer_name);
    printf("\n");
}

Adding a new order with a o Jake NONE TOFU SALAD should look something like this:

Before:

02_02_add_order_before

After:

02_02_add_order_after

Errors

When adding an order, if any of the following conditions are met then the order should not be added, and the corresponding error message should be printed instead:

  • If a customer with name [name] does not exist, the following error should be printed:
    "ERROR: Customer '[name]' not found\n"
    where [name] is the name of the customer.
  • If the order flavour returned by the scan_flavour() function is INVALID_FLAVOUR, the following error should be printed:
    "ERROR: Invalid flavour\n"
  • If the order protein returned by the scan_protein() function is INVALID_PROTEIN, the following error should be printed:
    "ERROR: Invalid protein\n"
  • If the order base returned by the scan_base() function is INVALID_BASE, the following error should be printed:
    "ERROR: Invalid base\n"
  • If the customer's balance would be less than $0 after the order is placed, the following error should be printed:
    "ERROR: Customer '[name]' has insufficient balance\n"

Examples

Input:

UNSW
a c Jake 100 11
p
a o Jake CHILLI CHICKEN CURRY
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#1' added: $19 item + $6 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $19
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
p
a o Jake CHILLI CHICKEN CURRY
a o Jake GARLIC LAMB WRAP
a o Jake NONE TOFU SALAD
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#1' added: $19 item + $6 delivery
Enter command: a o Jake GARLIC LAMB WRAP
Order '#2' added: $21 item + $6 delivery
Enter command: a o Jake NONE TOFU SALAD
Order '#3' added: $14 item + $6 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $54
[CUSTOMERS]
  Jake ($28, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake
    PENDING :: #2 Garlic Lamb Wrap :: Jake
    PENDING :: #3 Tofu Salad :: Jake

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
p
a o Grace GARLIC VEGGIE CURRY
a o Sofia LEMON CHICKEN NOODLES
a o Ibby SESAME BEEF WRAP
a o Ibby GARLIC CHICKEN CURRY
a o Sofia CHILLI LAMB WRAP
a o Grace LEMON CHICKEN SALAD
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: a o Grace GARLIC VEGGIE CURRY
Order '#1' added: $17 item + $5 delivery
Enter command: a o Sofia LEMON CHICKEN NOODLES
Order '#2' added: $17 item + $15 delivery
Enter command: a o Ibby SESAME BEEF WRAP
Order '#3' added: $19 item + $25 delivery
Enter command: a o Ibby GARLIC CHICKEN CURRY
ERROR: Customer 'Ibby' has insufficient balance
Enter command: a o Sofia CHILLI LAMB WRAP
ERROR: Customer 'Sofia' has insufficient balance
Enter command: a o Grace LEMON CHICKEN SALAD
Order '#4' added: $15 item + $5 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $68
[CUSTOMERS]
  Grace ($8, 10 km)
  Ibby ($6, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    PENDING :: #1 Garlic Veggie Curry :: Grace
    PENDING :: #2 Lemon Chicken Noodles :: Sofia
    PENDING :: #3 Sesame Beef Wrap :: Ibby
    PENDING :: #4 Lemon Chicken Salad :: Grace

Enter command: q
Goodbye!

Input:

UNSW
a o Jake CHILLI CHICKEN CURRY
a c Jake 100 11
a o Sasha CHILLI CHICKEN CURRY
a o Jake SESAME BEEF NOODLES
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a o Jake CHILLI CHICKEN CURRY
ERROR: Customer 'Jake' not found
Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Sasha CHILLI CHICKEN CURRY
ERROR: Customer 'Sasha' not found
Enter command: a o Jake SESAME BEEF NOODLES
Order '#1' added: $19 item + $6 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $19
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    PENDING :: #1 Sesame Beef Noodles :: Jake

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake X CHICKEN CURRY
a o Jake CHILLI X CURRY
a o Jake CHILLI CHICKEN X
a o Jake CHILLI X X
a o Jake X CHICKEN X
a o Jake X X CURRY
a o Jake X X X
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake X CHICKEN CURRY
ERROR: Invalid flavour
Enter command: a o Jake CHILLI X CURRY
ERROR: Invalid protein
Enter command: a o Jake CHILLI CHICKEN X
ERROR: Invalid base
Enter command: a o Jake CHILLI X X
ERROR: Invalid protein
Enter command: a o Jake X CHICKEN X
ERROR: Invalid flavour
Enter command: a o Jake X X CURRY
ERROR: Invalid flavour
Enter command: a o Jake X X X
ERROR: Invalid flavour
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Andrew 100 65
a o Andrew GARLIC LAMB CURRY
p
a o Andrew LEMON TOFU SALAD
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Andrew 100 65
Customer 'Andrew' added
Enter command: a o Andrew GARLIC LAMB CURRY
Order '#1' added: $23 item + $60 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $23
[CUSTOMERS]
  Andrew ($17, 65 km)
[ORDERS]
    PENDING :: #1 Garlic Lamb Curry :: Andrew

Enter command: a o Andrew LEMON TOFU SALAD
ERROR: Customer 'Andrew' has insufficient balance
Enter command: p
******************[ UNSW ]******************
Profit: $23
[CUSTOMERS]
  Andrew ($17, 65 km)
[ORDERS]
    PENDING :: #1 Garlic Lamb Curry :: Andrew

Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • [flavour], [protein], and [base] are strings.

Stage 2.3 - Loyalty Discount

While taking a break to sharpen their knives, the chef notices a familiar name on the order list and slices a few dollars off the bill.

Description

When an add order command is entered, your program should give a loyalty discount to returning customers according to the following rules:

  • Each customer receives a $5 loyalty discount on every 4th order they make. For example, if a customer makes an order and it is their 4th order, they receive $5 off that order. They will also receive $5 off their 8th order, 12th order, and so on.
  • The loyalty discount reduces the amount paid by the customer, so it also reduces the restaurant's profit by the same amount. However, the loyalty discount does not affect the delivery fee.
  • Only successful orders are counted. If an order fails due to an error, it does not count towards the customer's next loyalty discount.

If an order receives a loyalty discount, the add order success message should also include the loyalty discount:
"Order '#[id]' added: $[item_price] item + $[delivery_fee] delivery - $[discount] discount\n"
where:
[id] is the unique identification number of the order.
[item_price] is the price of the food item being ordered.
[delivery_fee] is the order's delivery fee.
[discount] is the loyalty discount applied to the order.

Examples

Input:

UNSW
a c Jake 211 11
p
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
p
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
p
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
a o Jake CHILLI CHICKEN CURRY
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 211 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($211, 11 km)
[ORDERS]
  (no orders)

Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#1' added: $19 item + $6 delivery
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#2' added: $19 item + $6 delivery
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#3' added: $19 item + $6 delivery
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#4' added: $19 item + $6 delivery - $5 discount
Enter command: p
******************[ UNSW ]******************
Profit: $71
[CUSTOMERS]
  Jake ($116, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake
    PENDING :: #2 Chilli Chicken Curry :: Jake
    PENDING :: #3 Chilli Chicken Curry :: Jake
    PENDING :: #4 Chilli Chicken Curry :: Jake

Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#5' added: $19 item + $6 delivery
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#6' added: $19 item + $6 delivery
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#7' added: $19 item + $6 delivery
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#8' added: $19 item + $6 delivery - $5 discount
Enter command: p
******************[ UNSW ]******************
Profit: $142
[CUSTOMERS]
  Jake ($21, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake
    PENDING :: #2 Chilli Chicken Curry :: Jake
    PENDING :: #3 Chilli Chicken Curry :: Jake
    PENDING :: #4 Chilli Chicken Curry :: Jake
    PENDING :: #5 Chilli Chicken Curry :: Jake
    PENDING :: #6 Chilli Chicken Curry :: Jake
    PENDING :: #7 Chilli Chicken Curry :: Jake
    PENDING :: #8 Chilli Chicken Curry :: Jake

Enter command: a o Jake CHILLI CHICKEN CURRY
ERROR: Customer 'Jake' has insufficient balance
Enter command: a o Jake CHILLI CHICKEN CURRY
ERROR: Customer 'Jake' has insufficient balance
Enter command: a o Jake CHILLI CHICKEN CURRY
ERROR: Customer 'Jake' has insufficient balance
Enter command: a o Jake CHILLI CHICKEN CURRY
ERROR: Customer 'Jake' has insufficient balance
Enter command: p
******************[ UNSW ]******************
Profit: $142
[CUSTOMERS]
  Jake ($21, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake
    PENDING :: #2 Chilli Chicken Curry :: Jake
    PENDING :: #3 Chilli Chicken Curry :: Jake
    PENDING :: #4 Chilli Chicken Curry :: Jake
    PENDING :: #5 Chilli Chicken Curry :: Jake
    PENDING :: #6 Chilli Chicken Curry :: Jake
    PENDING :: #7 Chilli Chicken Curry :: Jake
    PENDING :: #8 Chilli Chicken Curry :: Jake

Enter command: q
Goodbye!

Clarifications

  • N/A.

Stage 2.4 - Cook Orders

The kitchen is alive! Turn up the heat and "let them cook"!

Command

c [n: int]

The cook order command consists of "c" followed by the number of orders that the restaurant should cook. For example, the command:

c 3

would cook up to 3 orders in the restaurant's order list.

Description

When a cook order(s) command is entered, your program should cook up to [n] orders in the restaurant's order list.

Starting from the head of the list of orders, restaurant staff will cook any order with a PENDING status until they either cook [n] orders, or there are no PENDING orders remaining.

When an order is cooked:

  • The order status should be updated to READY.
  • The order's cost-to-cook (described below) should be subtracted from the restaurant's profit.

When the cooking command is complete, the program should print
"Cooked [amount] order(s)\n"
where [amount] is the number of orders that were cooked.

The cost-to-cook an order is equal to:

  • A fixed $4 labour cost.
  • PLUS half of the order's base price, determined by the order_base, as described in Stage 2.2

Note: all base prices are even. There is no integer rounding when dividing these prices by two.

Examples

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
a o Sofia LEMON CHICKEN NOODLES
a o Ibby SESAME BEEF SALAD
a o Grace GARLIC VEGGIE CURRY
p
c 1
p
c 1
p
c 1
p
c 1
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: a o Sofia LEMON CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby SESAME BEEF SALAD
Order '#2' added: $17 item + $25 delivery
Enter command: a o Grace GARLIC VEGGIE CURRY
Order '#3' added: $17 item + $5 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    PENDING :: #1 Lemon Chicken Noodles :: Sofia
    PENDING :: #2 Sesame Beef Salad :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $40
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    PENDING :: #2 Sesame Beef Salad :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $30
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    READY :: #2 Sesame Beef Salad :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $18
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    READY :: #2 Sesame Beef Salad :: Ibby
    READY :: #3 Garlic Veggie Curry :: Grace

Enter command: c 1
Cooked 0 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $18
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    READY :: #2 Sesame Beef Salad :: Ibby
    READY :: #3 Garlic Veggie Curry :: Grace

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
a o Sofia LEMON CHICKEN NOODLES
a o Ibby SESAME BEEF SALAD
a o Grace GARLIC VEGGIE CURRY
p
c 2
p
c 2
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: a o Sofia LEMON CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby SESAME BEEF SALAD
Order '#2' added: $17 item + $25 delivery
Enter command: a o Grace GARLIC VEGGIE CURRY
Order '#3' added: $17 item + $5 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    PENDING :: #1 Lemon Chicken Noodles :: Sofia
    PENDING :: #2 Sesame Beef Salad :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: c 2
Cooked 2 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $30
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    READY :: #2 Sesame Beef Salad :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: c 2
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $18
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    READY :: #2 Sesame Beef Salad :: Ibby
    READY :: #3 Garlic Veggie Curry :: Grace

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
a o Sofia LEMON CHICKEN NOODLES
a o Ibby SESAME BEEF SALAD
a o Grace GARLIC VEGGIE CURRY
p
c 999
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: a o Sofia LEMON CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby SESAME BEEF SALAD
Order '#2' added: $17 item + $25 delivery
Enter command: a o Grace GARLIC VEGGIE CURRY
Order '#3' added: $17 item + $5 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    PENDING :: #1 Lemon Chicken Noodles :: Sofia
    PENDING :: #2 Sesame Beef Salad :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: c 999
Cooked 3 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $18
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($8, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    READY :: #1 Lemon Chicken Noodles :: Sofia
    READY :: #2 Sesame Beef Salad :: Ibby
    READY :: #3 Garlic Veggie Curry :: Grace

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake CHILLI CHICKEN CURRY
p
c 0
c -1
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake CHILLI CHICKEN CURRY
Order '#1' added: $19 item + $6 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $19
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake

Enter command: c 0
Cooked 0 order(s)
Enter command: c -1
Cooked 0 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $19
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Curry :: Jake

Enter command: q
Goodbye!

Clarifications

  • [n] is an integer.
  • If [n] is less than or equal to zero, no orders are cooked.
  • It is possible for the restaurant's profit to be a negative integer.

Stage 2.5 - Deliver Orders

Each order is a boxed masterpiece with steam curling up through the vents. The city is about to get a taste of success!

In this stage, you take ready orders from the restaurant and ensure they reach the right customers.

Command

d [order_id: int]

The deliver order command consists of a "d" followed by the unique identification number [order_id] of the order to deliver. For example, the command:

d 7

would deliver order number 7 to its assigned customer.

Description

When a deliver order command is entered, your program should:

  • Search the restaurant's order list for an order whose [id] number matches [order_id].
  • Remove the matching order from the restaurant's list.
  • Append the order to the tail of the relevant customer's order list.
  • Update the order's status to DELIVERED.

When the delivery is complete, the program should print
"Order '#[id]' delivered to '[name]'\n"
where:

  • [id] is the identification number of the order.
  • [name] is the name of the customer who received the order.

Delivering an order with d 5 should look something like this:

Before:

02_05_delivery_order_before

After:

02_05_delivery_order_after

Errors

When delivering an order, if any of the following conditions are met then the order should not be delivered, and the corresponding error message should be printed instead:

  • If an order with [id] is present in any of the customer's order lists (i.e. in case it has already been delivered), the following error should be printed:
    "ERROR: Order '#[id]' already delivered\n"
    where [id] is the identification number of the order.
  • Otherwise, if an order with [id] does not exist in the restaurant's order list, the following error should be printed:
    "ERROR: Order '#[id]' not found\n"
  • If an order with [id] exists in the restaurant's order list but does not have a status of READY, the following error should be printed:
    "ERROR: Order '#[id]' not READY\n"

Examples

Input:

UNSW
a c Jake 100 11
a o Jake LEMON LAMB SALAD
c 1
p
d 1
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON LAMB SALAD
Order '#1' added: $19 item + $6 delivery
Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $9
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    READY :: #1 Lemon Lamb Salad :: Jake

Enter command: d 1
Order '#1' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $9
[CUSTOMERS]
  Jake ($75, 11 km)
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake LEMON LAMB SALAD
a o Jake LEMON LAMB SALAD
a o Jake LEMON LAMB SALAD
a o Jake LEMON LAMB SALAD
c 4
p
d 3
p
d 1
p
d 4
p
d 2
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON LAMB SALAD
Order '#1' added: $19 item + $6 delivery
Enter command: a o Jake LEMON LAMB SALAD
Order '#2' added: $19 item + $6 delivery
Enter command: a o Jake LEMON LAMB SALAD
Order '#3' added: $19 item + $6 delivery
Enter command: a o Jake LEMON LAMB SALAD
Order '#4' added: $19 item + $6 delivery - $5 discount
Enter command: c 4
Cooked 4 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $31
[CUSTOMERS]
  Jake ($5, 11 km)
[ORDERS]
    READY :: #1 Lemon Lamb Salad :: Jake
    READY :: #2 Lemon Lamb Salad :: Jake
    READY :: #3 Lemon Lamb Salad :: Jake
    READY :: #4 Lemon Lamb Salad :: Jake

Enter command: d 3
Order '#3' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $31
[CUSTOMERS]
  Jake ($5, 11 km)
    DELIVERED :: #3 Lemon Lamb Salad :: Jake
[ORDERS]
    READY :: #1 Lemon Lamb Salad :: Jake
    READY :: #2 Lemon Lamb Salad :: Jake
    READY :: #4 Lemon Lamb Salad :: Jake

Enter command: d 1
Order '#1' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $31
[CUSTOMERS]
  Jake ($5, 11 km)
    DELIVERED :: #3 Lemon Lamb Salad :: Jake
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
[ORDERS]
    READY :: #2 Lemon Lamb Salad :: Jake
    READY :: #4 Lemon Lamb Salad :: Jake

Enter command: d 4
Order '#4' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $31
[CUSTOMERS]
  Jake ($5, 11 km)
    DELIVERED :: #3 Lemon Lamb Salad :: Jake
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
    DELIVERED :: #4 Lemon Lamb Salad :: Jake
[ORDERS]
    READY :: #2 Lemon Lamb Salad :: Jake

Enter command: d 2
Order '#2' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $31
[CUSTOMERS]
  Jake ($5, 11 km)
    DELIVERED :: #3 Lemon Lamb Salad :: Jake
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
    DELIVERED :: #4 Lemon Lamb Salad :: Jake
    DELIVERED :: #2 Lemon Lamb Salad :: Jake
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 150 20
a c Ibby 150 30
a c Grace 150 10
a o Sofia CHILLI CHICKEN NOODLES
a o Ibby GARLIC BEEF CURRY
a o Grace SESAME CHICKEN SOUP
a o Sofia CHILLI BEEF WRAP
a o Ibby LEMON CHICKEN WRAP
a o Grace CHILLI VEGGIE SOUP
a o Sofia GARLIC CHICKEN SALAD
a o Ibby SESAME LAMB NOODLES
a o Grace LEMON LAMB SALAD
c 9
p
d 4
p
d 5
p
d 6
p
d 9
p
d 8
p
d 7
p
d 1
p
d 2
p
d 3
p
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a o Sofia CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby GARLIC BEEF CURRY
Order '#2' added: $21 item + $25 delivery
Enter command: a o Grace SESAME CHICKEN SOUP
Order '#3' added: $13 item + $5 delivery
Enter command: a o Sofia CHILLI BEEF WRAP
Order '#4' added: $19 item + $15 delivery
Enter command: a o Ibby LEMON CHICKEN WRAP
Order '#5' added: $17 item + $25 delivery
Enter command: a o Grace CHILLI VEGGIE SOUP
Order '#6' added: $11 item + $5 delivery
Enter command: a o Sofia GARLIC CHICKEN SALAD
Order '#7' added: $15 item + $15 delivery
Enter command: a o Ibby SESAME LAMB NOODLES
Order '#8' added: $21 item + $25 delivery
Enter command: a o Grace LEMON LAMB SALAD
Order '#9' added: $19 item + $5 delivery
Enter command: c 9
Cooked 9 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
  Ibby ($16, 30 km)
  Sofia ($54, 20 km)
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #4 Chilli Beef Wrap :: Sofia
    READY :: #5 Lemon Chicken Wrap :: Ibby
    READY :: #6 Chilli Veggie Soup :: Grace
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby
    READY :: #9 Lemon Lamb Salad :: Grace

Enter command: d 4
Order '#4' delivered to 'Sofia'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
  Ibby ($16, 30 km)
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #5 Lemon Chicken Wrap :: Ibby
    READY :: #6 Chilli Veggie Soup :: Grace
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby
    READY :: #9 Lemon Lamb Salad :: Grace

Enter command: d 5
Order '#5' delivered to 'Ibby'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #6 Chilli Veggie Soup :: Grace
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby
    READY :: #9 Lemon Lamb Salad :: Grace

Enter command: d 6
Order '#6' delivered to 'Grace'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby
    READY :: #9 Lemon Lamb Salad :: Grace

Enter command: d 9
Order '#9' delivered to 'Grace'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
    DELIVERED :: #9 Lemon Lamb Salad :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby

Enter command: d 8
Order '#8' delivered to 'Ibby'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
    DELIVERED :: #9 Lemon Lamb Salad :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #8 Sesame Lamb Noodles :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #7 Garlic Chicken Salad :: Sofia

Enter command: d 7
Order '#7' delivered to 'Sofia'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
    DELIVERED :: #9 Lemon Lamb Salad :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #8 Sesame Lamb Noodles :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
    DELIVERED :: #7 Garlic Chicken Salad :: Sofia
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace

Enter command: d 1
Order '#1' delivered to 'Sofia'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
    DELIVERED :: #9 Lemon Lamb Salad :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #8 Sesame Lamb Noodles :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
    DELIVERED :: #7 Garlic Chicken Salad :: Sofia
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
[ORDERS]
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace

Enter command: d 2
Order '#2' delivered to 'Ibby'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
    DELIVERED :: #9 Lemon Lamb Salad :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #8 Sesame Lamb Noodles :: Ibby
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
    DELIVERED :: #7 Garlic Chicken Salad :: Sofia
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
[ORDERS]
    READY :: #3 Sesame Chicken Soup :: Grace

Enter command: d 3
Order '#3' delivered to 'Grace'
Enter command: p
******************[ UNSW ]******************
Profit: $59
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
    DELIVERED :: #9 Lemon Lamb Salad :: Grace
    DELIVERED :: #3 Sesame Chicken Soup :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #8 Sesame Lamb Noodles :: Ibby
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
    DELIVERED :: #7 Garlic Chicken Salad :: Sofia
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
p
d 1
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: d 1
ERROR: Order '#1' not found
Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake LEMON LAMB SALAD
c 1
d 1
p
d 1
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON LAMB SALAD
Order '#1' added: $19 item + $6 delivery
Enter command: c 1
Cooked 1 order(s)
Enter command: d 1
Order '#1' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $9
[CUSTOMERS]
  Jake ($75, 11 km)
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
[ORDERS]
  (no orders)

Enter command: d 1
ERROR: Order '#1' already delivered
Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake LEMON LAMB SALAD
p
d 1
q

Input and Output:

dcc main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON LAMB SALAD
Order '#1' added: $19 item + $6 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $19
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    PENDING :: #1 Lemon Lamb Salad :: Jake

Enter command: d 1
ERROR: Order '#1' not READY
Enter command: q
Goodbye!

Clarifications

  • [order_id] is an integer.
  • You may assume that, if an order exists, the order's customer will also exist.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_eats.c
1511 style cs_eats.h
1511 style main.c
1511 autotest-stage 02 cs_eats
give cs1511 ass2_cs_eats cs_eats.c cs_eats.h main.c

Stage 3

The dinner rush has eased, the lights are dimming, and CS Eats switches from cooking to cleaning. It's time to tackle the chores: power down safely, cancel leftover orders, and remove the remaining customers.

Stage 3 will focus on deleting nodes and memory management. This milestone has been divided into four substages:

  • Stage 3.1 - Close Restaurant.
  • Stage 3.2 - Cancel Orders.
  • Stage 3.3 - Remove Customers.
  • Stage 3.4 - Customer Eats.
  • Stage 3.5 - Merge.

Stage 3.1 - Close Restaurant

It's the end of the day. The head chef turns off the ovens, hangs up their hat, and ensures that staff leave the kitchen spotless. Not even a single byte can be left behind!

In this stage, you will ensure CS Eats can shut down gracefully by traversing every list and freeing all allocated memory before the program exits.

Description

From this stage onwards, when a quit 'q' command is entered, your program should free any memory that was allocated with malloc() before the program exits.

Examples

Input:

UNSW
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
p
a o Sofia LEMON CHICKEN NOODLES
a o Ibby SESAME BEEF WRAP
a o Grace GARLIC VEGGIE CURRY
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 50 20
Customer 'Sofia' added
Enter command: a c Ibby 50 30
Customer 'Ibby' added
Enter command: a c Grace 50 10
Customer 'Grace' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Grace ($50, 10 km)
  Ibby ($50, 30 km)
  Sofia ($50, 20 km)
[ORDERS]
  (no orders)

Enter command: a o Sofia LEMON CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby SESAME BEEF WRAP
Order '#2' added: $19 item + $25 delivery
Enter command: a o Grace GARLIC VEGGIE CURRY
Order '#3' added: $17 item + $5 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $53
[CUSTOMERS]
  Grace ($28, 10 km)
  Ibby ($6, 30 km)
  Sofia ($18, 20 km)
[ORDERS]
    PENDING :: #1 Lemon Chicken Noodles :: Sofia
    PENDING :: #2 Sesame Beef Wrap :: Ibby
    PENDING :: #3 Garlic Veggie Curry :: Grace

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 150 20
a c Ibby 150 30
a c Grace 150 10
a o Sofia CHILLI CHICKEN NOODLES
a o Ibby GARLIC BEEF CURRY
a o Grace SESAME CHICKEN SOUP
a o Sofia CHILLI BEEF WRAP
a o Ibby LEMON CHICKEN WRAP
a o Grace CHILLI VEGGIE SOUP
a o Sofia GARLIC CHICKEN SALAD
a o Ibby SESAME LAMB NOODLES
a o Grace LEMON LAMB SALAD
c 6
p
d 1
d 2
d 3
d 4
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a o Sofia CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby GARLIC BEEF CURRY
Order '#2' added: $21 item + $25 delivery
Enter command: a o Grace SESAME CHICKEN SOUP
Order '#3' added: $13 item + $5 delivery
Enter command: a o Sofia CHILLI BEEF WRAP
Order '#4' added: $19 item + $15 delivery
Enter command: a o Ibby LEMON CHICKEN WRAP
Order '#5' added: $17 item + $25 delivery
Enter command: a o Grace CHILLI VEGGIE SOUP
Order '#6' added: $11 item + $5 delivery
Enter command: a o Sofia GARLIC CHICKEN SALAD
Order '#7' added: $15 item + $15 delivery
Enter command: a o Ibby SESAME LAMB NOODLES
Order '#8' added: $21 item + $25 delivery
Enter command: a o Grace LEMON LAMB SALAD
Order '#9' added: $19 item + $5 delivery
Enter command: c 6
Cooked 6 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $90
[CUSTOMERS]
  Grace ($92, 10 km)
  Ibby ($16, 30 km)
  Sofia ($54, 20 km)
[ORDERS]
    READY :: #1 Chilli Chicken Noodles :: Sofia
    READY :: #2 Garlic Beef Curry :: Ibby
    READY :: #3 Sesame Chicken Soup :: Grace
    READY :: #4 Chilli Beef Wrap :: Sofia
    READY :: #5 Lemon Chicken Wrap :: Ibby
    READY :: #6 Chilli Veggie Soup :: Grace
    PENDING :: #7 Garlic Chicken Salad :: Sofia
    PENDING :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Grace

Enter command: d 1
Order '#1' delivered to 'Sofia'
Enter command: d 2
Order '#2' delivered to 'Ibby'
Enter command: d 3
Order '#3' delivered to 'Grace'
Enter command: d 4
Order '#4' delivered to 'Sofia'
Enter command: p
******************[ UNSW ]******************
Profit: $90
[CUSTOMERS]
  Grace ($92, 10 km)
    DELIVERED :: #3 Sesame Chicken Soup :: Grace
  Ibby ($16, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #5 Lemon Chicken Wrap :: Ibby
    READY :: #6 Chilli Veggie Soup :: Grace
    PENDING :: #7 Garlic Chicken Salad :: Sofia
    PENDING :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Grace

Enter command: q
Goodbye!

Clarifications

In this stage, and in all subsequent stages:

  • Autotests and marking tests will check for memory leaks by compiling with
    dcc --leak-check.
  • If your code allocates memory with malloc() but does not free it with free() before the program terminates, your program will fail autotests and final marking tests.

Stage 3.2 - Cancel Orders

"Oops! We already have chilli chicken noodles at home!" - Customer

In this stage, you introduce order cancellations and refunds to customers.

Command

x o [order_id: int]

The cancel order command consists of "x o" followed by the [order_id] of the order to be cancelled. For example, the command:

x o 5

would cancel the order with an identification number equal to 5.

Description

When a cancel order command is entered, your program should remove the order from the restaurant's order list.

If an order was successfully removed:

  • The customer should be refunded the order price (minus the order's loyalty discount, if any) and the delivery fee.
  • The restaurant's profit should be adjusted to subtract the order price (minus the loyalty discount, if any) paid by the customer.

When the cancel order command is complete, the program should print
"Order '#[order_id]' removed\n".

Errors

When cancelling an order, if any of the following conditions are met then the order should not be cancelled, and the corresponding error message should be printed instead:

  • If an order with [order_id] does not exist in the restaurant's order list, the following error should be printed:
    "ERROR: Order '#[order_id]' not at restaurant\n"
  • If an order with [order_id] exists in the restaurant's order list but does not have a status of PENDING, the following error should be printed:
    "ERROR: Order '#[order_id]' not in PENDING state\n"

Examples

Input:

UNSW
a c Sofia 150 20
a c Ibby 150 30
a c Grace 150 10
a o Sofia NONE CHICKEN CURRY
a o Sofia SESAME TOFU WRAP
a o Sofia SESAME BEEF SALAD
c 1
p
x o 2
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a o Sofia NONE CHICKEN CURRY
Order '#1' added: $18 item + $15 delivery
Enter command: a o Sofia SESAME TOFU WRAP
Order '#2' added: $17 item + $15 delivery
Enter command: a o Sofia SESAME BEEF SALAD
Order '#3' added: $17 item + $15 delivery
Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $40
[CUSTOMERS]
  Grace ($150, 10 km)
  Ibby ($150, 30 km)
  Sofia ($53, 20 km)
[ORDERS]
    READY :: #1 Chicken Curry :: Sofia
    PENDING :: #2 Sesame Tofu Wrap :: Sofia
    PENDING :: #3 Sesame Beef Salad :: Sofia

Enter command: x o 2
Order '#2' removed
Enter command: p
******************[ UNSW ]******************
Profit: $23
[CUSTOMERS]
  Grace ($150, 10 km)
  Ibby ($150, 30 km)
  Sofia ($85, 20 km)
[ORDERS]
    READY :: #1 Chicken Curry :: Sofia
    PENDING :: #3 Sesame Beef Salad :: Sofia

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 150 20
a c Ibby 150 30
a c Grace 150 10
a o Sofia NONE CHICKEN CURRY
a o Ibby GARLIC TOFU NOODLES
a o Grace LEMON BEEF NOODLES
a o Sofia SESAME TOFU WRAP
a o Ibby CHILLI TOFU CURRY
a o Grace SESAME BEEF SALAD
c 3
p
x o 5
p
x o 4
p
x o 6
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a o Sofia NONE CHICKEN CURRY
Order '#1' added: $18 item + $15 delivery
Enter command: a o Ibby GARLIC TOFU NOODLES
Order '#2' added: $17 item + $25 delivery
Enter command: a o Grace LEMON BEEF NOODLES
Order '#3' added: $19 item + $5 delivery
Enter command: a o Sofia SESAME TOFU WRAP
Order '#4' added: $17 item + $15 delivery
Enter command: a o Ibby CHILLI TOFU CURRY
Order '#5' added: $19 item + $25 delivery
Enter command: a o Grace SESAME BEEF SALAD
Order '#6' added: $17 item + $5 delivery
Enter command: c 3
Cooked 3 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $73
[CUSTOMERS]
  Grace ($104, 10 km)
  Ibby ($64, 30 km)
  Sofia ($85, 20 km)
[ORDERS]
    READY :: #1 Chicken Curry :: Sofia
    READY :: #2 Garlic Tofu Noodles :: Ibby
    READY :: #3 Lemon Beef Noodles :: Grace
    PENDING :: #4 Sesame Tofu Wrap :: Sofia
    PENDING :: #5 Chilli Tofu Curry :: Ibby
    PENDING :: #6 Sesame Beef Salad :: Grace

Enter command: x o 5
Order '#5' removed
Enter command: p
******************[ UNSW ]******************
Profit: $54
[CUSTOMERS]
  Grace ($104, 10 km)
  Ibby ($108, 30 km)
  Sofia ($85, 20 km)
[ORDERS]
    READY :: #1 Chicken Curry :: Sofia
    READY :: #2 Garlic Tofu Noodles :: Ibby
    READY :: #3 Lemon Beef Noodles :: Grace
    PENDING :: #4 Sesame Tofu Wrap :: Sofia
    PENDING :: #6 Sesame Beef Salad :: Grace

Enter command: x o 4
Order '#4' removed
Enter command: p
******************[ UNSW ]******************
Profit: $37
[CUSTOMERS]
  Grace ($104, 10 km)
  Ibby ($108, 30 km)
  Sofia ($117, 20 km)
[ORDERS]
    READY :: #1 Chicken Curry :: Sofia
    READY :: #2 Garlic Tofu Noodles :: Ibby
    READY :: #3 Lemon Beef Noodles :: Grace
    PENDING :: #6 Sesame Beef Salad :: Grace

Enter command: x o 6
Order '#6' removed
Enter command: p
******************[ UNSW ]******************
Profit: $20
[CUSTOMERS]
  Grace ($126, 10 km)
  Ibby ($108, 30 km)
  Sofia ($117, 20 km)
[ORDERS]
    READY :: #1 Chicken Curry :: Sofia
    READY :: #2 Garlic Tofu Noodles :: Ibby
    READY :: #3 Lemon Beef Noodles :: Grace

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake LEMON LAMB SALAD
a o Jake LEMON LAMB SALAD
c 1
d 1
p
x o 1
x o 3
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON LAMB SALAD
Order '#1' added: $19 item + $6 delivery
Enter command: a o Jake LEMON LAMB SALAD
Order '#2' added: $19 item + $6 delivery
Enter command: c 1
Cooked 1 order(s)
Enter command: d 1
Order '#1' delivered to 'Jake'
Enter command: p
******************[ UNSW ]******************
Profit: $28
[CUSTOMERS]
  Jake ($50, 11 km)
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
[ORDERS]
    PENDING :: #2 Lemon Lamb Salad :: Jake

Enter command: x o 1
ERROR: Order '#1' not at restaurant
Enter command: x o 3
ERROR: Order '#3' not at restaurant
Enter command: p
******************[ UNSW ]******************
Profit: $28
[CUSTOMERS]
  Jake ($50, 11 km)
    DELIVERED :: #1 Lemon Lamb Salad :: Jake
[ORDERS]
    PENDING :: #2 Lemon Lamb Salad :: Jake

Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake LEMON LAMB SALAD
c 1
p
x o 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON LAMB SALAD
Order '#1' added: $19 item + $6 delivery
Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $9
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    READY :: #1 Lemon Lamb Salad :: Jake

Enter command: x o 1
ERROR: Order '#1' not in PENDING state
Enter command: p
******************[ UNSW ]******************
Profit: $9
[CUSTOMERS]
  Jake ($75, 11 km)
[ORDERS]
    READY :: #1 Lemon Lamb Salad :: Jake

Enter command: q
Goodbye!

Clarifications

  • [order_id] is an integer.
  • When a cancelled order is removed from an order list, all its associated memory should be freed.
  • You may assume that, if an order exists, the order's customer will also exist.
  • Refunds for cancelled orders don't affect the loyalty discounts applied to subsequent new orders. For example:
    • If a customer adds four orders and their 4th order (the order with a loyalty discount) is then cancelled, the loyalty discount is not carried forward to the customer's 5th order. The next order to receive a loyalty discount will be the customer's 8th order, as though the cancellation did not occur.

Stage 3.3 - Remove Customers

After a month of nightly noodles, Andrew swears off takeaway (for a while 😅). Their account disappears off the chef's screen.

In this stage, you allow CS Eats to remove customers, but only once all their orders have been delivered.

Command

x c [name: string]

The remove customer command consists of "x c" followed by the [name] of the customer to be removed. For example, the command:

x c Andrew

would remove the customer with name Andrew.

Description

When the remove customer command is entered, your program should remove the customer and any orders that have been delivered to them.

When the remove customer command is complete, the program should print
"Customer '[name]' removed\n".

Errors

When removing a customer, if any of the following conditions are met then the customer should not be removed, and the corresponding error message should be printed instead:

  • If a customer with name [name] does not exist in the restaurant's customer list, the following error should be printed:
    "ERROR: Customer '[name]' not found\n"

  • If a customer with name [name] exists in the restaurant's customer list but an order assigned to their name exists with a status that is not DELIVERED, the following error should be printed and the customer remains in the restaurant:
    "ERROR: Customer '[name]' has undelivered orders\n"

Examples

Input:

UNSW
a c Andrew 150 60
a c Sofia 150 20
a c Ibby 150 30
a c Grace 150 10
a o Andrew SESAME TOFU CURRY
a o Andrew GARLIC VEGGIE WRAP
c 2
d 1
d 2
p
x c Andrew
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Andrew 150 60
Customer 'Andrew' added
Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a o Andrew SESAME TOFU CURRY
Order '#1' added: $19 item + $55 delivery
Enter command: a o Andrew GARLIC VEGGIE WRAP
Order '#2' added: $15 item + $55 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Andrew'
Enter command: p
******************[ UNSW ]******************
Profit: $11
[CUSTOMERS]
  Grace ($150, 10 km)
  Ibby ($150, 30 km)
  Sofia ($150, 20 km)
  Andrew ($6, 60 km)
    DELIVERED :: #1 Sesame Tofu Curry :: Andrew
    DELIVERED :: #2 Garlic Veggie Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: x c Andrew
Customer 'Andrew' removed
Enter command: p
******************[ UNSW ]******************
Profit: $11
[CUSTOMERS]
  Grace ($150, 10 km)
  Ibby ($150, 30 km)
  Sofia ($150, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Andrew 150 60
a c Sofia 150 20
a c Ibby 150 30
a c Grace 150 10
a o Andrew SESAME TOFU CURRY
a o Sofia CHILLI CHICKEN NOODLES
a o Ibby GARLIC BEEF CURRY
a o Grace SESAME CHICKEN SOUP
a o Andrew GARLIC VEGGIE WRAP
a o Sofia CHILLI BEEF WRAP
a o Ibby LEMON CHICKEN WRAP
a o Grace CHILLI VEGGIE SOUP
c 8
d 1
d 2
d 3
d 4
d 5
d 6
d 7
d 8
p
x c Ibby
p
x c Andrew
p
x c Grace
p
x c Sofia
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Andrew 150 60
Customer 'Andrew' added
Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a o Andrew SESAME TOFU CURRY
Order '#1' added: $19 item + $55 delivery
Enter command: a o Sofia CHILLI CHICKEN NOODLES
Order '#2' added: $17 item + $15 delivery
Enter command: a o Ibby GARLIC BEEF CURRY
Order '#3' added: $21 item + $25 delivery
Enter command: a o Grace SESAME CHICKEN SOUP
Order '#4' added: $13 item + $5 delivery
Enter command: a o Andrew GARLIC VEGGIE WRAP
Order '#5' added: $15 item + $55 delivery
Enter command: a o Sofia CHILLI BEEF WRAP
Order '#6' added: $19 item + $15 delivery
Enter command: a o Ibby LEMON CHICKEN WRAP
Order '#7' added: $17 item + $25 delivery
Enter command: a o Grace CHILLI VEGGIE SOUP
Order '#8' added: $11 item + $5 delivery
Enter command: c 8
Cooked 8 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Sofia'
Enter command: d 3
Order '#3' delivered to 'Ibby'
Enter command: d 4
Order '#4' delivered to 'Grace'
Enter command: d 5
Order '#5' delivered to 'Andrew'
Enter command: d 6
Order '#6' delivered to 'Sofia'
Enter command: d 7
Order '#7' delivered to 'Ibby'
Enter command: d 8
Order '#8' delivered to 'Grace'
Enter command: p
******************[ UNSW ]******************
Profit: $46
[CUSTOMERS]
  Grace ($116, 10 km)
    DELIVERED :: #4 Sesame Chicken Soup :: Grace
    DELIVERED :: #8 Chilli Veggie Soup :: Grace
  Ibby ($62, 30 km)
    DELIVERED :: #3 Garlic Beef Curry :: Ibby
    DELIVERED :: #7 Lemon Chicken Wrap :: Ibby
  Sofia ($84, 20 km)
    DELIVERED :: #2 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #6 Chilli Beef Wrap :: Sofia
  Andrew ($6, 60 km)
    DELIVERED :: #1 Sesame Tofu Curry :: Andrew
    DELIVERED :: #5 Garlic Veggie Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: x c Ibby
Customer 'Ibby' removed
Enter command: p
******************[ UNSW ]******************
Profit: $46
[CUSTOMERS]
  Grace ($116, 10 km)
    DELIVERED :: #4 Sesame Chicken Soup :: Grace
    DELIVERED :: #8 Chilli Veggie Soup :: Grace
  Sofia ($84, 20 km)
    DELIVERED :: #2 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #6 Chilli Beef Wrap :: Sofia
  Andrew ($6, 60 km)
    DELIVERED :: #1 Sesame Tofu Curry :: Andrew
    DELIVERED :: #5 Garlic Veggie Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: x c Andrew
Customer 'Andrew' removed
Enter command: p
******************[ UNSW ]******************
Profit: $46
[CUSTOMERS]
  Grace ($116, 10 km)
    DELIVERED :: #4 Sesame Chicken Soup :: Grace
    DELIVERED :: #8 Chilli Veggie Soup :: Grace
  Sofia ($84, 20 km)
    DELIVERED :: #2 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #6 Chilli Beef Wrap :: Sofia
[ORDERS]
  (no orders)

Enter command: x c Grace
Customer 'Grace' removed
Enter command: p
******************[ UNSW ]******************
Profit: $46
[CUSTOMERS]
  Sofia ($84, 20 km)
    DELIVERED :: #2 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #6 Chilli Beef Wrap :: Sofia
[ORDERS]
  (no orders)

Enter command: x c Sofia
Customer 'Sofia' removed
Enter command: p
******************[ UNSW ]******************
Profit: $46
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
x c Andrew
a c Jake 100 11
p
x c Andrew
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: x c Andrew
ERROR: Customer 'Andrew' not found
Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: x c Andrew
ERROR: Customer 'Andrew' not found
Enter command: q
Goodbye!

Input:

UNSW
a c Jake 100 11
a o Jake LEMON VEGGIE NOODLES
p
x c Jake
c 1
p
x c Jake
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: a o Jake LEMON VEGGIE NOODLES
Order '#1' added: $15 item + $6 delivery
Enter command: p
******************[ UNSW ]******************
Profit: $15
[CUSTOMERS]
  Jake ($79, 11 km)
[ORDERS]
    PENDING :: #1 Lemon Veggie Noodles :: Jake

Enter command: x c Jake
ERROR: Customer 'Jake' has undelivered orders
Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $4
[CUSTOMERS]
  Jake ($79, 11 km)
[ORDERS]
    READY :: #1 Lemon Veggie Noodles :: Jake

Enter command: x c Jake
ERROR: Customer 'Jake' has undelivered orders
Enter command: q
Goodbye!

Clarifications

  • When a customer is removed from the customer list, all its associated memory should be freed.

Stage 3.4 - Eat

A cool breeze, a cardboard box, and zero dishes to wash... Dinner is served!

In Stage 3.4 customers will eat their food.

Command

e [name: string] [position: int] [amount: int]

The eat command consists of "e" followed by a customer [name], a [position] to start eating from, and the [amount] of orders to eat. For example, the command:

e Andrew 3 2

would cause customer Andrew to start eating from the third order in their order list, until they have eaten a total of two orders.

Description

When the eat command is entered, your program should remove the specified [amount] of orders from the customer's order list, starting from the order at position [position].

When the remove eating command is complete, the program should print
"'[name]' ate [amount] order(s)\n"

Errors

When eating food, if any of the following conditions are met then no food should be eaten, and the corresponding error message should be printed instead:

  • If a customer with name [name] does not exist in the restaurant's customer list, the following error should be printed:
    "ERROR: Customer '[name]' not found\n"

  • If the customer has no order at position [position] in their order list, the following error should be printed:
    "ERROR: Customer '[name]' has no order at position '[position]'\n"

  • If the [amount] entered is less than or equal to zero, the following error should be printed:
    "ERROR: Amount must be positive\n"

  • If the combination of [position] and [amount] entered would result in the customer attempting to eat an order with a position beyond the tail of their order list, the following error should be printed:
    "ERROR: Customer '[name]' wants to eat too many orders\n"

Examples

Input:

UNSW
a c Sofia 1000 20
a c Ibby 1000 30
a c Andrew 1000 60
a c Grace 1000 10
a o Andrew CHILLI CHICKEN NOODLES
a o Andrew GARLIC BEEF CURRY
a o Andrew SESAME CHICKEN SOUP
a o Andrew CHILLI BEEF WRAP
c 4
d 1
d 2
d 3
d 4
p
e Andrew 4 1
p
e Andrew 2 1
p
e Andrew 1 1
p
e Andrew 1 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 1000 20
Customer 'Sofia' added
Enter command: a c Ibby 1000 30
Customer 'Ibby' added
Enter command: a c Andrew 1000 60
Customer 'Andrew' added
Enter command: a c Grace 1000 10
Customer 'Grace' added
Enter command: a o Andrew CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $55 delivery
Enter command: a o Andrew GARLIC BEEF CURRY
Order '#2' added: $21 item + $55 delivery
Enter command: a o Andrew SESAME CHICKEN SOUP
Order '#3' added: $13 item + $55 delivery
Enter command: a o Andrew CHILLI BEEF WRAP
Order '#4' added: $19 item + $55 delivery - $5 discount
Enter command: c 4
Cooked 4 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Andrew'
Enter command: d 3
Order '#3' delivered to 'Andrew'
Enter command: d 4
Order '#4' delivered to 'Andrew'
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($715, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
    DELIVERED :: #4 Chilli Beef Wrap :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 4 1
'Andrew' ate 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($715, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 2 1
'Andrew' ate 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($715, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 1 1
'Andrew' ate 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($715, 60 km)
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 1 1
'Andrew' ate 1 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($715, 60 km)
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 1000 20
a c Ibby 1000 30
a c Andrew 1000 60
a c Grace 1000 10
a o Andrew CHILLI CHICKEN NOODLES
a o Andrew GARLIC BEEF CURRY
a o Andrew SESAME CHICKEN SOUP
a o Andrew CHILLI BEEF WRAP
a o Andrew LEMON LAMB SALAD
a o Andrew NONE VEGGIE SOUP
a o Andrew SESAME TOFU WRAP
a o Andrew GARLIC CHICKEN SALAD
a o Andrew CHILLI TOFU CURRY
a o Andrew NONE CHICKEN CURRY
c 10
d 1
d 2
d 3
d 4
d 5
d 6
d 7
d 8
d 9
d 10
p
e Andrew 9 2
p
e Andrew 3 3
p
e Andrew 1 2
p
e Andrew 1 3
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 1000 20
Customer 'Sofia' added
Enter command: a c Ibby 1000 30
Customer 'Ibby' added
Enter command: a c Andrew 1000 60
Customer 'Andrew' added
Enter command: a c Grace 1000 10
Customer 'Grace' added
Enter command: a o Andrew CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $55 delivery
Enter command: a o Andrew GARLIC BEEF CURRY
Order '#2' added: $21 item + $55 delivery
Enter command: a o Andrew SESAME CHICKEN SOUP
Order '#3' added: $13 item + $55 delivery
Enter command: a o Andrew CHILLI BEEF WRAP
Order '#4' added: $19 item + $55 delivery - $5 discount
Enter command: a o Andrew LEMON LAMB SALAD
Order '#5' added: $19 item + $55 delivery
Enter command: a o Andrew NONE VEGGIE SOUP
Order '#6' added: $10 item + $55 delivery
Enter command: a o Andrew SESAME TOFU WRAP
Order '#7' added: $17 item + $55 delivery
Enter command: a o Andrew GARLIC CHICKEN SALAD
Order '#8' added: $15 item + $55 delivery - $5 discount
Enter command: a o Andrew CHILLI TOFU CURRY
Order '#9' added: $19 item + $55 delivery
Enter command: a o Andrew NONE CHICKEN CURRY
Order '#10' added: $18 item + $55 delivery
Enter command: c 10
Cooked 10 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Andrew'
Enter command: d 3
Order '#3' delivered to 'Andrew'
Enter command: d 4
Order '#4' delivered to 'Andrew'
Enter command: d 5
Order '#5' delivered to 'Andrew'
Enter command: d 6
Order '#6' delivered to 'Andrew'
Enter command: d 7
Order '#7' delivered to 'Andrew'
Enter command: d 8
Order '#8' delivered to 'Andrew'
Enter command: d 9
Order '#9' delivered to 'Andrew'
Enter command: d 10
Order '#10' delivered to 'Andrew'
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($292, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
    DELIVERED :: #4 Chilli Beef Wrap :: Andrew
    DELIVERED :: #5 Lemon Lamb Salad :: Andrew
    DELIVERED :: #6 Veggie Soup :: Andrew
    DELIVERED :: #7 Sesame Tofu Wrap :: Andrew
    DELIVERED :: #8 Garlic Chicken Salad :: Andrew
    DELIVERED :: #9 Chilli Tofu Curry :: Andrew
    DELIVERED :: #10 Chicken Curry :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 9 2
'Andrew' ate 2 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($292, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
    DELIVERED :: #4 Chilli Beef Wrap :: Andrew
    DELIVERED :: #5 Lemon Lamb Salad :: Andrew
    DELIVERED :: #6 Veggie Soup :: Andrew
    DELIVERED :: #7 Sesame Tofu Wrap :: Andrew
    DELIVERED :: #8 Garlic Chicken Salad :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 3 3
'Andrew' ate 3 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($292, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #6 Veggie Soup :: Andrew
    DELIVERED :: #7 Sesame Tofu Wrap :: Andrew
    DELIVERED :: #8 Garlic Chicken Salad :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 1 2
'Andrew' ate 2 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($292, 60 km)
    DELIVERED :: #6 Veggie Soup :: Andrew
    DELIVERED :: #7 Sesame Tofu Wrap :: Andrew
    DELIVERED :: #8 Garlic Chicken Salad :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 1 3
'Andrew' ate 3 order(s)
Enter command: p
******************[ UNSW ]******************
Profit: $51
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($292, 60 km)
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
e Andrew 1 1
a c Jake 100 11
p
e Andrew 1 1
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: e Andrew 1 1
ERROR: Customer 'Andrew' not found
Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: e Andrew 1 1
ERROR: Customer 'Andrew' not found
Enter command: q
Goodbye!

Input:

UNSW
a c Sofia 1000 20
a c Ibby 1000 30
a c Andrew 1000 60
a c Grace 1000 10
a o Andrew CHILLI CHICKEN NOODLES
a o Andrew GARLIC BEEF CURRY
c 2
d 1
d 2
p
e Andrew -1 1
e Andrew 0 1
e Andrew 3 1
e Sofia 1 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Sofia 1000 20
Customer 'Sofia' added
Enter command: a c Ibby 1000 30
Customer 'Ibby' added
Enter command: a c Andrew 1000 60
Customer 'Andrew' added
Enter command: a c Grace 1000 10
Customer 'Grace' added
Enter command: a o Andrew CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $55 delivery
Enter command: a o Andrew GARLIC BEEF CURRY
Order '#2' added: $21 item + $55 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Andrew'
Enter command: p
******************[ UNSW ]******************
Profit: $15
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($852, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: e Andrew -1 1
ERROR: Customer 'Andrew' has no order at position '-1'
Enter command: e Andrew 0 1
ERROR: Customer 'Andrew' has no order at position '0'
Enter command: e Andrew 3 1
ERROR: Customer 'Andrew' has no order at position '3'
Enter command: e Sofia 1 1
ERROR: Customer 'Sofia' has no order at position '1'
Enter command: p
******************[ UNSW ]******************
Profit: $15
[CUSTOMERS]
  Grace ($1000, 10 km)
  Andrew ($852, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
  Ibby ($1000, 30 km)
  Sofia ($1000, 20 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Andrew 1000 60
a o Andrew CHILLI CHICKEN NOODLES
a o Andrew GARLIC BEEF CURRY
c 2
d 1
d 2
p
e Andrew 1 0
e Andrew 1 -1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Andrew 1000 60
Customer 'Andrew' added
Enter command: a o Andrew CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $55 delivery
Enter command: a o Andrew GARLIC BEEF CURRY
Order '#2' added: $21 item + $55 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Andrew'
Enter command: p
******************[ UNSW ]******************
Profit: $15
[CUSTOMERS]
  Andrew ($852, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
[ORDERS]
  (no orders)

Enter command: e Andrew 1 0
ERROR: Amount must be positive
Enter command: e Andrew 1 -1
ERROR: Amount must be positive
Enter command: p
******************[ UNSW ]******************
Profit: $15
[CUSTOMERS]
  Andrew ($852, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

UNSW
a c Andrew 1000 60
a o Andrew CHILLI CHICKEN NOODLES
a o Andrew GARLIC BEEF CURRY
a o Andrew SESAME CHICKEN SOUP
a o Andrew CHILLI BEEF WRAP
c 4
d 1
d 2
d 3
d 4
p
e Andrew 1 5
e Andrew 2 4
e Andrew 3 3
e Andrew 4 2
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Andrew 1000 60
Customer 'Andrew' added
Enter command: a o Andrew CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $55 delivery
Enter command: a o Andrew GARLIC BEEF CURRY
Order '#2' added: $21 item + $55 delivery
Enter command: a o Andrew SESAME CHICKEN SOUP
Order '#3' added: $13 item + $55 delivery
Enter command: a o Andrew CHILLI BEEF WRAP
Order '#4' added: $19 item + $55 delivery - $5 discount
Enter command: c 4
Cooked 4 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: d 2
Order '#2' delivered to 'Andrew'
Enter command: d 3
Order '#3' delivered to 'Andrew'
Enter command: d 4
Order '#4' delivered to 'Andrew'
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Andrew ($715, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
    DELIVERED :: #4 Chilli Beef Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: e Andrew 1 5
ERROR: Customer 'Andrew' wants to eat too many orders
Enter command: e Andrew 2 4
ERROR: Customer 'Andrew' wants to eat too many orders
Enter command: e Andrew 3 3
ERROR: Customer 'Andrew' wants to eat too many orders
Enter command: e Andrew 4 2
ERROR: Customer 'Andrew' wants to eat too many orders
Enter command: p
******************[ UNSW ]******************
Profit: $22
[CUSTOMERS]
  Andrew ($715, 60 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Andrew
    DELIVERED :: #2 Garlic Beef Curry :: Andrew
    DELIVERED :: #3 Sesame Chicken Soup :: Andrew
    DELIVERED :: #4 Chilli Beef Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • [position] and [amount] are integers.
  • When an order is removed from a customer's order list, all its associated memory should be freed.

Stage 3.5 - Merge

Three apartments in the same building are all tapping "Pay" for wraps on a Wednesday. So CS Eats bundles them all into one delivery address.

In this stage, you will consolidate customers who live near one another.

Command

m [name: string] [distance: int]

The merge command consists of an "m" followed by a destination customer's [name] and the [distance] for within which other customers should be merged into [name]. For example, the command:

m Jake 8

would merge all customers within an 8 km distance of Jake.

Definitions

  • Destination Customer: the customer named in the merge command.

  • Source Customer: any customer whose distance is within [distance] kilometres (inclusive) from the destination customer.

For example: if Jake is a destination customer with a distance of 11 km from the restaurant, then any customer with a distance value between 3 km and 19 km (inclusive) is a source customer since they are within 8 km from Jake.

Description

When the merge command is entered your program should, starting from the head of the customer list, find every source customer and merge them into the destination customer according to the following rules:

  • The source customer's orders should be appended in their original order to the tail of the destination customer's order list.
  • All the source customer's orders should be reassigned to the destination customer.
  • The source customer's balance should be added to the destination customer's balance.
  • The source customer should be removed from the restaurant's customer list.

Errors

When merging customers, if any of the following conditions are met then no customers should be merged, and the corresponding error message should be printed instead:

  • If a customer with the name [name] does not exist in the restaurant's customer list, the following error should be printed:
    "ERROR: Customer '[name]' not found\n"
  • If the [distance] entered is less than or equal to zero, the following error should be printed:
    "ERROR: Distance must be positive\n"

Examples

Input:

UNSW
a c Customer_1 100 10
a c Customer_2 200 20
a o Customer_1 CHILLI CHICKEN NOODLES
a o Customer_2 GARLIC LAMB WRAP
a o Customer_1 CHILLI CHICKEN NOODLES
a o Customer_2 GARLIC LAMB WRAP
c 2
d 1
d 2
p
m Customer_1 50
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Customer_1 100 10
Customer 'Customer_1' added
Enter command: a c Customer_2 200 20
Customer 'Customer_2' added
Enter command: a o Customer_1 CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $5 delivery
Enter command: a o Customer_2 GARLIC LAMB WRAP
Order '#2' added: $21 item + $15 delivery
Enter command: a o Customer_1 CHILLI CHICKEN NOODLES
Order '#3' added: $17 item + $5 delivery
Enter command: a o Customer_2 GARLIC LAMB WRAP
Order '#4' added: $21 item + $15 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: d 1
Order '#1' delivered to 'Customer_1'
Enter command: d 2
Order '#2' delivered to 'Customer_2'
Enter command: p
******************[ UNSW ]******************
Profit: $54
[CUSTOMERS]
  Customer_2 ($128, 20 km)
    DELIVERED :: #2 Garlic Lamb Wrap :: Customer_2
  Customer_1 ($56, 10 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Customer_1
[ORDERS]
    PENDING :: #3 Chilli Chicken Noodles :: Customer_1
    PENDING :: #4 Garlic Lamb Wrap :: Customer_2

Enter command: m Customer_1 50
Enter command: p
******************[ UNSW ]******************
Profit: $54
[CUSTOMERS]
  Customer_1 ($184, 10 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Customer_1
    DELIVERED :: #2 Garlic Lamb Wrap :: Customer_1
[ORDERS]
    PENDING :: #3 Chilli Chicken Noodles :: Customer_1
    PENDING :: #4 Garlic Lamb Wrap :: Customer_1

Enter command: q
Goodbye!

Input:

UNSW
a c Customer_1 100 1
a c Customer_2 100 2
a c Customer_3 100 3
a c Customer_4 100 4
i c Customer_5 100 5 1
i c Customer_6 100 6 3
p
m Customer_4 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: UNSW

Enter command: a c Customer_1 100 1
Customer 'Customer_1' added
Enter command: a c Customer_2 100 2
Customer 'Customer_2' added
Enter command: a c Customer_3 100 3
Customer 'Customer_3' added
Enter command: a c Customer_4 100 4
Customer 'Customer_4' added
Enter command: i c Customer_5 100 5 1
Customer 'Customer_5' added
Enter command: i c Customer_6 100 6 3
Customer 'Customer_6' added
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Customer_5 ($100, 5 km)
  Customer_4 ($100, 4 km)
  Customer_6 ($100, 6 km)
  Customer_3 ($100, 3 km)
  Customer_2 ($100, 2 km)
  Customer_1 ($100, 1 km)
[ORDERS]
  (no orders)

Enter command: m Customer_4 1
Enter command: p
******************[ UNSW ]******************
Profit: $0
[CUSTOMERS]
  Customer_4 ($300, 4 km)
  Customer_6 ($100, 6 km)
  Customer_2 ($100, 2 km)
  Customer_1 ($100, 1 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

Wonton-In-A-Million
a c Sofia 150 20
a c Jake 300 11
a c Ibby 150 30
a c Sasha 300 13
a c Grace 150 10
a c Angela 300 8
a o Sofia CHILLI CHICKEN NOODLES
a o Ibby GARLIC BEEF CURRY
a o Grace SESAME CHICKEN SOUP
a o Sofia CHILLI BEEF WRAP
a o Ibby LEMON CHICKEN WRAP
a o Grace CHILLI VEGGIE SOUP
a o Sofia GARLIC CHICKEN SALAD
a o Ibby SESAME LAMB NOODLES
a o Grace LEMON LAMB SALAD
c 8
d 1
d 2
d 3
d 4
d 5
d 6
p
m Sasha 3
p
m Ibby 20
p
m Ibby 22
p
m Ibby 5
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Wonton-In-A-Million

Enter command: a c Sofia 150 20
Customer 'Sofia' added
Enter command: a c Jake 300 11
Customer 'Jake' added
Enter command: a c Ibby 150 30
Customer 'Ibby' added
Enter command: a c Sasha 300 13
Customer 'Sasha' added
Enter command: a c Grace 150 10
Customer 'Grace' added
Enter command: a c Angela 300 8
Customer 'Angela' added
Enter command: a o Sofia CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby GARLIC BEEF CURRY
Order '#2' added: $21 item + $25 delivery
Enter command: a o Grace SESAME CHICKEN SOUP
Order '#3' added: $13 item + $5 delivery
Enter command: a o Sofia CHILLI BEEF WRAP
Order '#4' added: $19 item + $15 delivery
Enter command: a o Ibby LEMON CHICKEN WRAP
Order '#5' added: $17 item + $25 delivery
Enter command: a o Grace CHILLI VEGGIE SOUP
Order '#6' added: $11 item + $5 delivery
Enter command: a o Sofia GARLIC CHICKEN SALAD
Order '#7' added: $15 item + $15 delivery
Enter command: a o Ibby SESAME LAMB NOODLES
Order '#8' added: $21 item + $25 delivery
Enter command: a o Grace LEMON LAMB SALAD
Order '#9' added: $19 item + $5 delivery
Enter command: c 8
Cooked 8 order(s)
Enter command: d 1
Order '#1' delivered to 'Sofia'
Enter command: d 2
Order '#2' delivered to 'Ibby'
Enter command: d 3
Order '#3' delivered to 'Grace'
Enter command: d 4
Order '#4' delivered to 'Sofia'
Enter command: d 5
Order '#5' delivered to 'Ibby'
Enter command: d 6
Order '#6' delivered to 'Grace'
Enter command: p
******************[ Wonton-In-A-Million ]******************
Profit: $69
[CUSTOMERS]
  Angela ($300, 8 km)
  Grace ($92, 10 km)
    DELIVERED :: #3 Sesame Chicken Soup :: Grace
    DELIVERED :: #6 Chilli Veggie Soup :: Grace
  Sasha ($300, 13 km)
  Ibby ($16, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
  Jake ($300, 11 km)
  Sofia ($54, 20 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Grace

Enter command: m Sasha 3
Enter command: p
******************[ Wonton-In-A-Million ]******************
Profit: $69
[CUSTOMERS]
  Angela ($300, 8 km)
  Sasha ($692, 13 km)
    DELIVERED :: #3 Sesame Chicken Soup :: Sasha
    DELIVERED :: #6 Chilli Veggie Soup :: Sasha
  Ibby ($16, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
  Sofia ($54, 20 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
    DELIVERED :: #4 Chilli Beef Wrap :: Sofia
[ORDERS]
    READY :: #7 Garlic Chicken Salad :: Sofia
    READY :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Sasha

Enter command: m Ibby 20
Enter command: p
******************[ Wonton-In-A-Million ]******************
Profit: $69
[CUSTOMERS]
  Angela ($300, 8 km)
  Ibby ($762, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #3 Sesame Chicken Soup :: Ibby
    DELIVERED :: #6 Chilli Veggie Soup :: Ibby
    DELIVERED :: #1 Chilli Chicken Noodles :: Ibby
    DELIVERED :: #4 Chilli Beef Wrap :: Ibby
[ORDERS]
    READY :: #7 Garlic Chicken Salad :: Ibby
    READY :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Ibby

Enter command: m Ibby 22
Enter command: p
******************[ Wonton-In-A-Million ]******************
Profit: $69
[CUSTOMERS]
  Ibby ($1062, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #3 Sesame Chicken Soup :: Ibby
    DELIVERED :: #6 Chilli Veggie Soup :: Ibby
    DELIVERED :: #1 Chilli Chicken Noodles :: Ibby
    DELIVERED :: #4 Chilli Beef Wrap :: Ibby
[ORDERS]
    READY :: #7 Garlic Chicken Salad :: Ibby
    READY :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Ibby

Enter command: m Ibby 5
Enter command: p
******************[ Wonton-In-A-Million ]******************
Profit: $69
[CUSTOMERS]
  Ibby ($1062, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
    DELIVERED :: #5 Lemon Chicken Wrap :: Ibby
    DELIVERED :: #3 Sesame Chicken Soup :: Ibby
    DELIVERED :: #6 Chilli Veggie Soup :: Ibby
    DELIVERED :: #1 Chilli Chicken Noodles :: Ibby
    DELIVERED :: #4 Chilli Beef Wrap :: Ibby
[ORDERS]
    READY :: #7 Garlic Chicken Salad :: Ibby
    READY :: #8 Sesame Lamb Noodles :: Ibby
    PENDING :: #9 Lemon Lamb Salad :: Ibby

Enter command: q
Goodbye!

Input:

NaN-Bread
p
m Jake 42
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: NaN-Bread

Enter command: p
******************[ NaN-Bread ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)

Enter command: m Jake 42
ERROR: Customer 'Jake' not found
Enter command: q
Goodbye!

Input:

Baguette-About-It
a c Jake 100 11
p
m Jake 0
m Jake -1
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Baguette-About-It

Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ Baguette-About-It ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: m Jake 0
ERROR: Distance must be positive
Enter command: m Jake -1
ERROR: Distance must be positive
Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • [distance] is an integer.
  • After merging, all orders are treated as if they were placed by the destination customer, including refunds and loyalty discounts.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_eats.c
1511 style cs_eats.h
1511 style main.c
1511 autotest-stage 03 cs_eats
give cs1511 ass2_cs_eats cs_eats.c cs_eats.h main.c

Stage 4

This stage is for students who want to challenge themselves and solve more complicated programming problems. This milestone has been divided into three substages:

  • Stage 4.1 - Sort.
  • Stage 4.2 - Reorder.
  • Stage 4.3 - Driver.

Stage 4.1 - Sort

The driver spreads a city map on the counter and, with a highlighter in hand, attempts to draw a single line between each of the customers.

"This will only take a minute." - the driver (3 hours ago)

In this stage, CS Eats rearranges the customer list to prepare an efficient delivery route.

Command

s

Description

When a sort command is entered, your program should rearrange the customer list so that:

  1. Customers whose distance is even appear first, sorted in ascending order of distance.
  2. Customers whose distance is odd appear after that, sorted in descending order of distance.
  3. If any two customers have the same distance, sort them in increasing lexicographic (ASCII) order by name.

Sorting a customer list with s should look something like this:

Before: 6, 11, 4, 5, 11, 4

02_01_insert_customer_before

After: 4, 4, 6, 11, 11, 5

02_01_insert_customer_after

Examples

Input:

Herb-Your-Enthusiasm
s
a c Jake 100 11
p
s
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Herb-Your-Enthusiasm

Enter command: s
Enter command: a c Jake 100 11
Customer 'Jake' added
Enter command: p
******************[ Herb-Your-Enthusiasm ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: s
Enter command: p
******************[ Herb-Your-Enthusiasm ]******************
Profit: $0
[CUSTOMERS]
  Jake ($100, 11 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

Paneerly-Beloved
a c Frank 100 42
a c Chris 100 15
a c David 100 16
a c Bella 100 8
a c Alex 100 4
a c Emma 100 23
p
s
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Paneerly-Beloved

Enter command: a c Frank 100 42
Customer 'Frank' added
Enter command: a c Chris 100 15
Customer 'Chris' added
Enter command: a c David 100 16
Customer 'David' added
Enter command: a c Bella 100 8
Customer 'Bella' added
Enter command: a c Alex 100 4
Customer 'Alex' added
Enter command: a c Emma 100 23
Customer 'Emma' added
Enter command: p
******************[ Paneerly-Beloved ]******************
Profit: $0
[CUSTOMERS]
  Emma ($100, 23 km)
  Alex ($100, 4 km)
  Bella ($100, 8 km)
  David ($100, 16 km)
  Chris ($100, 15 km)
  Frank ($100, 42 km)
[ORDERS]
  (no orders)

Enter command: s
Enter command: p
******************[ Paneerly-Beloved ]******************
Profit: $0
[CUSTOMERS]
  Alex ($100, 4 km)
  Bella ($100, 8 km)
  David ($100, 16 km)
  Frank ($100, 42 km)
  Emma ($100, 23 km)
  Chris ($100, 15 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

Suit-And-Thai
a c John 100 42
a c Johnathan 100 42
a c jo 100 42
a c Jo 100 42
a c john 100 42
a c johnathan 100 42
p
s
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Suit-And-Thai

Enter command: a c John 100 42
Customer 'John' added
Enter command: a c Johnathan 100 42
Customer 'Johnathan' added
Enter command: a c jo 100 42
Customer 'jo' added
Enter command: a c Jo 100 42
Customer 'Jo' added
Enter command: a c john 100 42
Customer 'john' added
Enter command: a c johnathan 100 42
Customer 'johnathan' added
Enter command: p
******************[ Suit-And-Thai ]******************
Profit: $0
[CUSTOMERS]
  johnathan ($100, 42 km)
  john ($100, 42 km)
  Jo ($100, 42 km)
  jo ($100, 42 km)
  Johnathan ($100, 42 km)
  John ($100, 42 km)
[ORDERS]
  (no orders)

Enter command: s
Enter command: p
******************[ Suit-And-Thai ]******************
Profit: $0
[CUSTOMERS]
  Jo ($100, 42 km)
  John ($100, 42 km)
  Johnathan ($100, 42 km)
  jo ($100, 42 km)
  john ($100, 42 km)
  johnathan ($100, 42 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Input:

Yum-Believable
a c Dennis_Ritchie 100 3
a c Ada_Lovelace 100 4
a c Ken_Thompson 100 11
a c Donald_Knuth 100 8
a c Radia_Perlman 100 5
a c Alan_Turing 100 2
a c Frances_Allen 100 9
a c Grace_Hopper 100 6
a c Tim_Berners_Lee 100 12
a c Claude_Shannon 100 10
a c Shafi_Goldwasser 100 5
a c Karen_Sparck_Jones 100 7
a c John_von_Neumann 100 1
a c Barbara_Liskov 100 4
a c Edsger_Dijkstra 100 11
a c Margaret_Hamilton 100 6
p
s
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Yum-Believable

Enter command: a c Dennis_Ritchie 100 3
Customer 'Dennis_Ritchie' added
Enter command: a c Ada_Lovelace 100 4
Customer 'Ada_Lovelace' added
Enter command: a c Ken_Thompson 100 11
Customer 'Ken_Thompson' added
Enter command: a c Donald_Knuth 100 8
Customer 'Donald_Knuth' added
Enter command: a c Radia_Perlman 100 5
Customer 'Radia_Perlman' added
Enter command: a c Alan_Turing 100 2
Customer 'Alan_Turing' added
Enter command: a c Frances_Allen 100 9
Customer 'Frances_Allen' added
Enter command: a c Grace_Hopper 100 6
Customer 'Grace_Hopper' added
Enter command: a c Tim_Berners_Lee 100 12
Customer 'Tim_Berners_Lee' added
Enter command: a c Claude_Shannon 100 10
Customer 'Claude_Shannon' added
Enter command: a c Shafi_Goldwasser 100 5
Customer 'Shafi_Goldwasser' added
Enter command: a c Karen_Sparck_Jones 100 7
Customer 'Karen_Sparck_Jones' added
Enter command: a c John_von_Neumann 100 1
Customer 'John_von_Neumann' added
Enter command: a c Barbara_Liskov 100 4
Customer 'Barbara_Liskov' added
Enter command: a c Edsger_Dijkstra 100 11
Customer 'Edsger_Dijkstra' added
Enter command: a c Margaret_Hamilton 100 6
Customer 'Margaret_Hamilton' added
Enter command: p
******************[ Yum-Believable ]******************
Profit: $0
[CUSTOMERS]
  Margaret_Hamilton ($100, 6 km)
  Edsger_Dijkstra ($100, 11 km)
  Barbara_Liskov ($100, 4 km)
  John_von_Neumann ($100, 1 km)
  Karen_Sparck_Jones ($100, 7 km)
  Shafi_Goldwasser ($100, 5 km)
  Claude_Shannon ($100, 10 km)
  Tim_Berners_Lee ($100, 12 km)
  Grace_Hopper ($100, 6 km)
  Frances_Allen ($100, 9 km)
  Alan_Turing ($100, 2 km)
  Radia_Perlman ($100, 5 km)
  Donald_Knuth ($100, 8 km)
  Ken_Thompson ($100, 11 km)
  Ada_Lovelace ($100, 4 km)
  Dennis_Ritchie ($100, 3 km)
[ORDERS]
  (no orders)

Enter command: s
Enter command: p
******************[ Yum-Believable ]******************
Profit: $0
[CUSTOMERS]
  Alan_Turing ($100, 2 km)
  Ada_Lovelace ($100, 4 km)
  Barbara_Liskov ($100, 4 km)
  Grace_Hopper ($100, 6 km)
  Margaret_Hamilton ($100, 6 km)
  Donald_Knuth ($100, 8 km)
  Claude_Shannon ($100, 10 km)
  Tim_Berners_Lee ($100, 12 km)
  Edsger_Dijkstra ($100, 11 km)
  Ken_Thompson ($100, 11 km)
  Frances_Allen ($100, 9 km)
  Karen_Sparck_Jones ($100, 7 km)
  Radia_Perlman ($100, 5 km)
  Shafi_Goldwasser ($100, 5 km)
  Dennis_Ritchie ($100, 3 km)
  John_von_Neumann ($100, 1 km)
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Clarifications

  • Customer names can contain any printable ASCII characters (except for whitespace). This means that "ABC-abc-XD-!!!1-Jake" is a valid customer name.

Stage 4.2 - Reorder

The driver steps out of the lift with a fragrant box...

"Whatever that is, send one my way." - the neighbour

In this stage, CS Eats offers a new feature for customers to reorder past orders, including those placed by other customers.

Definitions

  • Past Order: Any order that was previously placed by any customer of the restaurant, including:
    • Orders that have been delivered or cancelled.
    • Orders belonging to customers who have since been deleted.

Command

r [name: string] [n: int] [id_1: int] [id_2: int] ... [id_n: int]

The reorder command consists of "r" followed by a customer name [name] (the person making the order), a number of orders [n], and a list of past order ids to reorder.

The command:

r Jake 2 7 3

would reorder the 2 past orders with IDs 7 and 3 for customer Jake.

The command:

r Sasha 6 4 8 15 16 23 42

would reorder the 6 past orders with IDs 4, 8, 15, 16, 23 and 42 for customer Sasha.

Description

When a reorder command is entered, your program should:

  1. Scan in the customer's [name] and the number of orders [n]. Note, [name] represents the customer placing the new order, not necessarily the customer who placed the past orders.

  2. For each of the subsequent order identification [id] numbers, your program should add a new order to the restaurant's order list. The new order should:

    • Be made for customer [name].
    • Have a PENDING status.
    • Have a new unique identification number.
    • Contain the same menu item (flavour, protein and base) as the past order whose identification number is equal to [id].
    • Have the same financial effects as if an identical order had been added with the add order command. That is, the new order should increase the restaurant's profit, decrease the customer's balance, and include any applicable loyalty discount.
  3. Reordered orders are processed in the same sequence that they appear in the reorder command's argument list.

  4. For each new order, print a message to confirm that the reorder was successful:

  • If there was no loyalty discount:
    "Order '#[id]' added: $[item_price] item + $[delivery_fee] delivery\n"

  • If a loyalty discount was applied:
    "Order '#[id]' added: $[item_price] item + $[delivery_fee] delivery - $[discount] discount\n"
    where:
    [id] is the unique identification number of the order.
    [item_price] is the price of the food item being ordered.
    [delivery_fee] is the order's delivery fee.
    [discount] is the loyalty discount applied to the order.

Errors

When reordering, if any of the following conditions are met then no new orders should be added to the restaurant, and the corresponding error message should be printed instead:

  • If a customer with name [name] does not exist, the following error should be printed:
    "ERROR: Customer '[name]' not found\n"
    where [name] is the name of the customer.
  • If any [order_id] does not correspond to a known past order, print this once per invalid ID:\
  • "ERROR: Order '#[order_id]' is not a past order\n"
    where [order_id] is the id of the order that does not match.
  • If the customer's balance would be less than zero after all orders had been reordered, the following error should be printed:
    "ERROR: Customer '[name]' has insufficient balance\n"

Examples

Input:

Spaghettaboutit
a c Jake 1000 7
a o Jake SESAME CHICKEN SALAD
a o Jake GARLIC LAMB WRAP
p
r Jake 1 1
p
r Jake 1 2
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Spaghettaboutit

Enter command: a c Jake 1000 7
Customer 'Jake' added
Enter command: a o Jake SESAME CHICKEN SALAD
Order '#1' added: $15 item + $5 delivery
Enter command: a o Jake GARLIC LAMB WRAP
Order '#2' added: $21 item + $5 delivery
Enter command: p
******************[ Spaghettaboutit ]******************
Profit: $36
[CUSTOMERS]
  Jake ($954, 7 km)
[ORDERS]
    PENDING :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #2 Garlic Lamb Wrap :: Jake

Enter command: r Jake 1 1
Order '#3' added: $15 item + $5 delivery
Enter command: p
******************[ Spaghettaboutit ]******************
Profit: $51
[CUSTOMERS]
  Jake ($934, 7 km)
[ORDERS]
    PENDING :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #2 Garlic Lamb Wrap :: Jake
    PENDING :: #3 Sesame Chicken Salad :: Jake

Enter command: r Jake 1 2
Order '#4' added: $21 item + $5 delivery - $5 discount
Enter command: p
******************[ Spaghettaboutit ]******************
Profit: $67
[CUSTOMERS]
  Jake ($913, 7 km)
[ORDERS]
    PENDING :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #2 Garlic Lamb Wrap :: Jake
    PENDING :: #3 Sesame Chicken Salad :: Jake
    PENDING :: #4 Garlic Lamb Wrap :: Jake

Enter command: q
Goodbye!

Input:

Batter-Late-Than-Never
a c Jake 1000 7
a o Jake SESAME CHICKEN SALAD
a o Jake GARLIC LAMB WRAP
a o Jake CHILLI BEEF NOODLES
a o Jake NONE VEGGIE SOUP
c 3
d 2
d 3
p
x o 4
e Jake 2 1
p
r Jake 4 3 1 4 2
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Batter-Late-Than-Never

Enter command: a c Jake 1000 7
Customer 'Jake' added
Enter command: a o Jake SESAME CHICKEN SALAD
Order '#1' added: $15 item + $5 delivery
Enter command: a o Jake GARLIC LAMB WRAP
Order '#2' added: $21 item + $5 delivery
Enter command: a o Jake CHILLI BEEF NOODLES
Order '#3' added: $19 item + $5 delivery
Enter command: a o Jake NONE VEGGIE SOUP
Order '#4' added: $10 item + $5 delivery - $5 discount
Enter command: c 3
Cooked 3 order(s)
Enter command: d 2
Order '#2' delivered to 'Jake'
Enter command: d 3
Order '#3' delivered to 'Jake'
Enter command: p
******************[ Batter-Late-Than-Never ]******************
Profit: $28
[CUSTOMERS]
  Jake ($920, 7 km)
    DELIVERED :: #2 Garlic Lamb Wrap :: Jake
    DELIVERED :: #3 Chilli Beef Noodles :: Jake
[ORDERS]
    READY :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #4 Veggie Soup :: Jake

Enter command: x o 4
Order '#4' removed
Enter command: e Jake 2 1
'Jake' ate 1 order(s)
Enter command: p
******************[ Batter-Late-Than-Never ]******************
Profit: $23
[CUSTOMERS]
  Jake ($930, 7 km)
    DELIVERED :: #2 Garlic Lamb Wrap :: Jake
[ORDERS]
    READY :: #1 Sesame Chicken Salad :: Jake

Enter command: r Jake 4 3 1 4 2
Order '#5' added: $19 item + $5 delivery
Order '#6' added: $15 item + $5 delivery
Order '#7' added: $10 item + $5 delivery
Order '#8' added: $21 item + $5 delivery - $5 discount
Enter command: p
******************[ Batter-Late-Than-Never ]******************
Profit: $83
[CUSTOMERS]
  Jake ($850, 7 km)
    DELIVERED :: #2 Garlic Lamb Wrap :: Jake
[ORDERS]
    READY :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #5 Chilli Beef Noodles :: Jake
    PENDING :: #6 Sesame Chicken Salad :: Jake
    PENDING :: #7 Veggie Soup :: Jake
    PENDING :: #8 Garlic Lamb Wrap :: Jake

Enter command: q
Goodbye!

Input:

Braise_The_Roof
a c Sofia 1000 20
a c Ibby 1000 30
a c Grace 1000 10
a o Sofia CHILLI CHICKEN NOODLES
a o Ibby GARLIC BEEF CURRY
a o Sofia CHILLI BEEF WRAP
a o Ibby LEMON CHICKEN WRAP
p
c 2
d 1
d 2
p
r Grace 7 1 2 3 4 3 2 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Braise_The_Roof

Enter command: a c Sofia 1000 20
Customer 'Sofia' added
Enter command: a c Ibby 1000 30
Customer 'Ibby' added
Enter command: a c Grace 1000 10
Customer 'Grace' added
Enter command: a o Sofia CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $15 delivery
Enter command: a o Ibby GARLIC BEEF CURRY
Order '#2' added: $21 item + $25 delivery
Enter command: a o Sofia CHILLI BEEF WRAP
Order '#3' added: $19 item + $15 delivery
Enter command: a o Ibby LEMON CHICKEN WRAP
Order '#4' added: $17 item + $25 delivery
Enter command: p
******************[ Braise_The_Roof ]******************
Profit: $74
[CUSTOMERS]
  Grace ($1000, 10 km)
  Ibby ($912, 30 km)
  Sofia ($934, 20 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Noodles :: Sofia
    PENDING :: #2 Garlic Beef Curry :: Ibby
    PENDING :: #3 Chilli Beef Wrap :: Sofia
    PENDING :: #4 Lemon Chicken Wrap :: Ibby

Enter command: c 2
Cooked 2 order(s)
Enter command: d 1
Order '#1' delivered to 'Sofia'
Enter command: d 2
Order '#2' delivered to 'Ibby'
Enter command: p
******************[ Braise_The_Roof ]******************
Profit: $51
[CUSTOMERS]
  Grace ($1000, 10 km)
  Ibby ($912, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
  Sofia ($934, 20 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
[ORDERS]
    PENDING :: #3 Chilli Beef Wrap :: Sofia
    PENDING :: #4 Lemon Chicken Wrap :: Ibby

Enter command: r Grace 7 1 2 3 4 3 2 1
Order '#5' added: $17 item + $5 delivery
Order '#6' added: $21 item + $5 delivery
Order '#7' added: $19 item + $5 delivery
Order '#8' added: $17 item + $5 delivery - $5 discount
Order '#9' added: $19 item + $5 delivery
Order '#10' added: $21 item + $5 delivery
Order '#11' added: $17 item + $5 delivery
Enter command: p
******************[ Braise_The_Roof ]******************
Profit: $177
[CUSTOMERS]
  Grace ($839, 10 km)
  Ibby ($912, 30 km)
    DELIVERED :: #2 Garlic Beef Curry :: Ibby
  Sofia ($934, 20 km)
    DELIVERED :: #1 Chilli Chicken Noodles :: Sofia
[ORDERS]
    PENDING :: #3 Chilli Beef Wrap :: Sofia
    PENDING :: #4 Lemon Chicken Wrap :: Ibby
    PENDING :: #5 Chilli Chicken Noodles :: Grace
    PENDING :: #6 Garlic Beef Curry :: Grace
    PENDING :: #7 Chilli Beef Wrap :: Grace
    PENDING :: #8 Lemon Chicken Wrap :: Grace
    PENDING :: #9 Chilli Beef Wrap :: Grace
    PENDING :: #10 Garlic Beef Curry :: Grace
    PENDING :: #11 Chilli Chicken Noodles :: Grace

Enter command: q
Goodbye!

Input:

Grillasaurus-Rex
a c Jake 1000 7
a o Jake CHILLI CHICKEN NOODLES
p
r Andrew 3 1 1 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Grillasaurus-Rex

Enter command: a c Jake 1000 7
Customer 'Jake' added
Enter command: a o Jake CHILLI CHICKEN NOODLES
Order '#1' added: $17 item + $5 delivery
Enter command: p
******************[ Grillasaurus-Rex ]******************
Profit: $17
[CUSTOMERS]
  Jake ($978, 7 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Noodles :: Jake

Enter command: r Andrew 3 1 1 1
ERROR: Customer 'Andrew' not found
Enter command: p
******************[ Grillasaurus-Rex ]******************
Profit: $17
[CUSTOMERS]
  Jake ($978, 7 km)
[ORDERS]
    PENDING :: #1 Chilli Chicken Noodles :: Jake

Enter command: q
Goodbye!

Input:

Pho-Sure
a c Jake 1000 7
a o Jake SESAME CHICKEN SALAD
a o Jake GARLIC LAMB WRAP
p
r Jake 4 0 1 2 3
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Pho-Sure

Enter command: a c Jake 1000 7
Customer 'Jake' added
Enter command: a o Jake SESAME CHICKEN SALAD
Order '#1' added: $15 item + $5 delivery
Enter command: a o Jake GARLIC LAMB WRAP
Order '#2' added: $21 item + $5 delivery
Enter command: p
******************[ Pho-Sure ]******************
Profit: $36
[CUSTOMERS]
  Jake ($954, 7 km)
[ORDERS]
    PENDING :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #2 Garlic Lamb Wrap :: Jake

Enter command: r Jake 4 0 1 2 3
ERROR: Order '#0' is not a past order
ERROR: Order '#3' is not a past order
Enter command: p
******************[ Pho-Sure ]******************
Profit: $36
[CUSTOMERS]
  Jake ($954, 7 km)
[ORDERS]
    PENDING :: #1 Sesame Chicken Salad :: Jake
    PENDING :: #2 Garlic Lamb Wrap :: Jake

Enter command: q
Goodbye!

Input:

Turnip-The-Heat
a c Andrew 100 3
a o Andrew GARLIC LAMB WRAP
c 1
d 1
p
r Andrew 4 1 1 1 1
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Turnip-The-Heat

Enter command: a c Andrew 100 3
Customer 'Andrew' added
Enter command: a o Andrew GARLIC LAMB WRAP
Order '#1' added: $21 item + $5 delivery
Enter command: c 1
Cooked 1 order(s)
Enter command: d 1
Order '#1' delivered to 'Andrew'
Enter command: p
******************[ Turnip-The-Heat ]******************
Profit: $10
[CUSTOMERS]
  Andrew ($74, 3 km)
    DELIVERED :: #1 Garlic Lamb Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: r Andrew 4 1 1 1 1
ERROR: Customer 'Andrew' has insufficient balance
Enter command: p
******************[ Turnip-The-Heat ]******************
Profit: $10
[CUSTOMERS]
  Andrew ($74, 3 km)
    DELIVERED :: #1 Garlic Lamb Wrap :: Andrew
[ORDERS]
  (no orders)

Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • [name] is the name of the customer placing the reorder, not necessarily the original orderer.
  • [n] is an integer greater than or equal to one.
  • Each number after [n] in the command is an integer order id.
  • You may assume that the command will include the correct number of order ids.
  • If any error occurs, then no orders are reordered.

Stage 4.3 - Driver

In this final stage, the program simulates a delivery driver as they collect and transport orders from the restaurant to customers.

The simulation progresses in turns, with the driver completing one action per turn.

There are three new commands in this stage:

  • Add driver which adds a new driver to the restaurant.
  • Simulate turn which advances the delivery simulation by one turn.
  • Fast forward which advances the delivery simulation by multiple turns.

Command 1: Add Driver

a d [name: string]

The add driver command consists of "a d" followed by the [name] of the driver. For example, the command:

a d Alex

would add the driver and name them Alex.

Description

When an add driver command is entered, your program should create the driver and add them to the restaurant.

During each turn, the driver will complete one of six possible actions:

  1. "1 - Waiting".
  2. "2 - Picking up".
  3. "3 - Departing".
  4. "4 - Transporting".
  5. "5 - Dropping off".
  6. "6 - Returning".

A newly-created driver will be "1 - Waiting".

You will need to modify the print_restaurant() function so that:

If a driver has been added, the output includes a "[DRIVER]" section.

  • If the driver is at the restaurant, the program should print the "[DRIVER]" heading followed by a small ASCII-art car and the driver's details. A helper function print_driver_details() has been provided to assist you. Check Example 4.3.1 to see how the driver should be printed.
  • If the driver is not at the restaurant, the program should print the "[DRIVER]" heading followed by " (no driver)", and show the driver underneath their current customer position instead.

// Function to print a driver's details (name, action)
// Params:
//      name   - the driver's name
//      action - the driver's most recent action
// Returns: None
// Usage:
// ```
//      print_driver_details(name, action);
// ```
void print_driver_details(char name[MAX_SIZE], char *action) {
    printf(
        "       __\n"
        "    .-'--`--. Driver: %s\n"
        "    '-O---O-' Action: %s\n",
        name,
        action
    );
}

After successfully adding the driver, print the following message:
"Driver '[name]' added\n"
where [name] is the name of the driver.

Errors

When adding the driver, if any of the following conditions are met then the driver should not be added, and the corresponding error message should be printed instead:

  • If the driver has already been added, the following error should be printed:
    "ERROR: Driver already exists\n"

Command 2: Simulate Turn

t

The simulate turn command advances the food delivery simulation by one turn.

Background

The driver has a maximum capacity of two orders. This means that the driver cannot carry more than two orders at a time.

The driver can move:

  • Forwards and backwards between customers.
  • Forwards from the restaurant to the head of the customer list.
  • Backwards from the restaurant to the tail of the customer list.
  • Forwards from the tail of the customer list to the restaurant.
  • Backwards from the head of the customer list to the restaurant.

Description

When a simulate turn command is entered, the driver should take one of the following actions:

Action 1: Wait for Orders

If the driver is at the restaurant, has no orders picked up, and no orders at the restaurant have a READY status, then the driver waits for orders to be cooked.

After a wait for orders action, the driver's action prints as "1 - Waiting".

Action 2: Pickup Orders

If the driver is at the restaurant, has capacity to carry additional orders, and there are orders available with a READY status, then they pick up as many orders as they have capacity for from the head of the restaurant's order list. This action occurs only if the driver is in the "Picking up" state and has not yet reached full capacity.

After a pickup orders action, the driver's action prints as "2 - Picking up".

When orders are picked up, their status changes from READY to EN_ROUTE.

Orders that are EN_ROUTE should not be printed in the restaurant's order list and instead be printed directly underneath the driver. Check Example 4.3.2 and Example 4.3.3 to see how EN_ROUTE orders are printed.

Action 3: Depart Restaurant

If the driver is at the restaurant, has picked up at least one order, and cannot pick up any more orders (because they are at maximum capacity, or because no new orders are ready), then they depart the restaurant.

Departing only occurs after a Pickup action has occurred. A driver will never be at the restaurant with orders unless they have already taken a Picking up action.

The driver departs by moving in one of two directions: forwards or backwards.

The direction of movement depends on the destination customer of the first order collected by the driver:

  • If the destination is closer to the head of the customer list, the driver moves forwards.
  • If the destination is closer to the tail of the customer list, the driver moves backwards.
  • If the destination is at the middle of the list, the driver moves forwards.

If the driver is not at the restaurant, then print_restaurant() should display the driver underneath the customer that they have moved to. Additionally, print_restaurant() should print " (no driver)" under the "[DRIVER]" heading. This is demonstrated in Example 4.3.2.

After a depart restaurant action, the driver's action prints as "3 - Departing".

Check the examples below to see how the driver is printed at the head or tail customer after departing the restaurant.

Action 4: Transport Orders

If the driver is not at the restaurant, is carrying undelivered orders, and is not located at a destination customer, then they transport orders by moving one node in the same direction they departed the restaurant.

After a transport orders action, the driver's action prints as "4 - Transporting".

Action 5: Drop-off Orders

If the driver is not at the restaurant, is carrying undelivered orders, and is located at a destination customer, then they deliver all orders that are for that customer to that customer.

When orders are dropped off, their status changes from EN_ROUTE to DELIVERED and they are appended to the tail of the customer's order list.

After a drop-off orders action, the driver's action prints as "5 - Dropping off".

Action 6: Return to Restaurant

If the driver is not at the restaurant, and is not carrying any orders, then they return to the restaurant by moving one node in the same direction they departed the restaurant.

When returning to the restaurant, the driver remains in the RETURNING status until they reach the restaurant. Once they arrive back at the restaurant, their state may transition to WAITING or PICKING UP status, depending on whether there are any READY orders and available capacity.

After a return to restaurant action, the driver's action prints as "6 - Returning".

End of Turn

Your program should call print_restaurant() at the end of each driver turn.

Command 3: Fast Forward

f [n: int]

The fast forward command advances the food delivery simulation by [n] turns. For example, the command:

f 3

would fast forward the delivery simulation by 3 turns.

Description

When a fast forward command is entered, the program should behave as if [n] simulate turn t commands had been entered, printing the restaurant once after all turns have been completed.

Examples

Input:

Ramen-Around-The-Clock
p
a d Driver1
p
a d Driver2
p
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Ramen-Around-The-Clock

Enter command: p
******************[ Ramen-Around-The-Clock ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)

Enter command: a d Driver1
Driver 'Driver1' added
Enter command: p
******************[ Ramen-Around-The-Clock ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Driver1
    '-O---O-' Action: 1 - Waiting

Enter command: a d Driver2
ERROR: Driver already exists
Enter command: p
******************[ Ramen-Around-The-Clock ]******************
Profit: $0
[CUSTOMERS]
  (no customers)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Driver1
    '-O---O-' Action: 1 - Waiting

Enter command: q
Goodbye!

Input:

Chew-Chew-Train
a d Hal_Appeno
a c Ada_Lovelace 100 3
a c Radia_Perlman 100 1
a c Alan_Turing 100 4
s
a o Ada_Lovelace LEMON TOFU SALAD
p
t
c 1
p
t
t
t
t
t
t
t
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Chew-Chew-Train

Enter command: a d Hal_Appeno
Driver 'Hal_Appeno' added
Enter command: a c Ada_Lovelace 100 3
Customer 'Ada_Lovelace' added
Enter command: a c Radia_Perlman 100 1
Customer 'Radia_Perlman' added
Enter command: a c Alan_Turing 100 4
Customer 'Alan_Turing' added
Enter command: s
Enter command: a o Ada_Lovelace LEMON TOFU SALAD
Order '#1' added: $15 item + $5 delivery
Enter command: p
******************[ Chew-Chew-Train ]******************
Profit: $15
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
  Radia_Perlman ($100, 1 km)
[ORDERS]
    PENDING :: #1 Lemon Tofu Salad :: Ada_Lovelace
[DRIVER]
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 1 - Waiting

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $15
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
  Radia_Perlman ($100, 1 km)
[ORDERS]
    PENDING :: #1 Lemon Tofu Salad :: Ada_Lovelace
[DRIVER]
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 1 - Waiting

Enter command: c 1
Cooked 1 order(s)
Enter command: p
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
  Radia_Perlman ($100, 1 km)
[ORDERS]
    READY :: #1 Lemon Tofu Salad :: Ada_Lovelace
[DRIVER]
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 1 - Waiting

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
  Radia_Perlman ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 2 - Picking up
    EN_ROUTE :: #1 Lemon Tofu Salad :: Ada_Lovelace

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 3 - Departing
    EN_ROUTE :: #1 Lemon Tofu Salad :: Ada_Lovelace
  Ada_Lovelace ($80, 3 km)
  Radia_Perlman ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #1 Lemon Tofu Salad :: Ada_Lovelace
  Radia_Perlman ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
    DELIVERED :: #1 Lemon Tofu Salad :: Ada_Lovelace
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 5 - Dropping off
  Radia_Perlman ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
    DELIVERED :: #1 Lemon Tofu Salad :: Ada_Lovelace
  Radia_Perlman ($100, 1 km)
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 6 - Returning
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
    DELIVERED :: #1 Lemon Tofu Salad :: Ada_Lovelace
  Radia_Perlman ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 6 - Returning

Enter command: t
******************[ Chew-Chew-Train ]******************
Profit: $5
[CUSTOMERS]
  Alan_Turing ($100, 4 km)
  Ada_Lovelace ($80, 3 km)
    DELIVERED :: #1 Lemon Tofu Salad :: Ada_Lovelace
  Radia_Perlman ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Hal_Appeno
    '-O---O-' Action: 1 - Waiting

Enter command: q
Goodbye!

Input:

Just-Dill-With-It
a d Brad_Pitta
a c Grace_Hopper 100 2
a c Donald_Knuth 100 6
s
a o Donald_Knuth CHILLI BEEF NOODLES
a o Grace_Hopper GARLIC LAMB CURRY
c 2
p
t
t
t
t
t
t
t
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Just-Dill-With-It

Enter command: a d Brad_Pitta
Driver 'Brad_Pitta' added
Enter command: a c Grace_Hopper 100 2
Customer 'Grace_Hopper' added
Enter command: a c Donald_Knuth 100 6
Customer 'Donald_Knuth' added
Enter command: s
Enter command: a o Donald_Knuth CHILLI BEEF NOODLES
Order '#1' added: $19 item + $5 delivery
Enter command: a o Grace_Hopper GARLIC LAMB CURRY
Order '#2' added: $23 item + $5 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: p
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
  Donald_Knuth ($76, 6 km)
[ORDERS]
    READY :: #1 Chilli Beef Noodles :: Donald_Knuth
    READY :: #2 Garlic Lamb Curry :: Grace_Hopper
[DRIVER]
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 1 - Waiting

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
  Donald_Knuth ($76, 6 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 2 - Picking up
    EN_ROUTE :: #1 Chilli Beef Noodles :: Donald_Knuth
    EN_ROUTE :: #2 Garlic Lamb Curry :: Grace_Hopper

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
  Donald_Knuth ($76, 6 km)
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 3 - Departing
    EN_ROUTE :: #1 Chilli Beef Noodles :: Donald_Knuth
    EN_ROUTE :: #2 Garlic Lamb Curry :: Grace_Hopper
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
  Donald_Knuth ($76, 6 km)
    DELIVERED :: #1 Chilli Beef Noodles :: Donald_Knuth
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 5 - Dropping off
    EN_ROUTE :: #2 Garlic Lamb Curry :: Grace_Hopper
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #2 Garlic Lamb Curry :: Grace_Hopper
  Donald_Knuth ($76, 6 km)
    DELIVERED :: #1 Chilli Beef Noodles :: Donald_Knuth
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
    DELIVERED :: #2 Garlic Lamb Curry :: Grace_Hopper
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 5 - Dropping off
  Donald_Knuth ($76, 6 km)
    DELIVERED :: #1 Chilli Beef Noodles :: Donald_Knuth
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
    DELIVERED :: #2 Garlic Lamb Curry :: Grace_Hopper
  Donald_Knuth ($76, 6 km)
    DELIVERED :: #1 Chilli Beef Noodles :: Donald_Knuth
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 6 - Returning

Enter command: t
******************[ Just-Dill-With-It ]******************
Profit: $19
[CUSTOMERS]
  Grace_Hopper ($72, 2 km)
    DELIVERED :: #2 Garlic Lamb Curry :: Grace_Hopper
  Donald_Knuth ($76, 6 km)
    DELIVERED :: #1 Chilli Beef Noodles :: Donald_Knuth
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Brad_Pitta
    '-O---O-' Action: 1 - Waiting

Enter command: q
Goodbye!

Input:

Nacho-Average-Kitchen
a d Justin_Thyme
a c Dennis_Ritchie 100 2
a c Radia_Perlman 100 4
a c Claude_Shannon 100 6
a c Karen_Sparck_Jones 100 5
a c Barbara_Liskov 100 1
s
a o Claude_Shannon SESAME CHICKEN WRAP
a o Claude_Shannon GARLIC VEGGIE WRAP
c 2
p
t
t
t
t
t
t
t
t
t
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Nacho-Average-Kitchen

Enter command: a d Justin_Thyme
Driver 'Justin_Thyme' added
Enter command: a c Dennis_Ritchie 100 2
Customer 'Dennis_Ritchie' added
Enter command: a c Radia_Perlman 100 4
Customer 'Radia_Perlman' added
Enter command: a c Claude_Shannon 100 6
Customer 'Claude_Shannon' added
Enter command: a c Karen_Sparck_Jones 100 5
Customer 'Karen_Sparck_Jones' added
Enter command: a c Barbara_Liskov 100 1
Customer 'Barbara_Liskov' added
Enter command: s
Enter command: a o Claude_Shannon SESAME CHICKEN WRAP
Order '#1' added: $17 item + $5 delivery
Enter command: a o Claude_Shannon GARLIC VEGGIE WRAP
Order '#2' added: $15 item + $5 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: p
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
    READY :: #1 Sesame Chicken Wrap :: Claude_Shannon
    READY :: #2 Garlic Veggie Wrap :: Claude_Shannon
[DRIVER]
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 1 - Waiting

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 2 - Picking up
    EN_ROUTE :: #1 Sesame Chicken Wrap :: Claude_Shannon
    EN_ROUTE :: #2 Garlic Veggie Wrap :: Claude_Shannon

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 3 - Departing
    EN_ROUTE :: #1 Sesame Chicken Wrap :: Claude_Shannon
    EN_ROUTE :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #1 Sesame Chicken Wrap :: Claude_Shannon
    EN_ROUTE :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Claude_Shannon ($58, 6 km)
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #1 Sesame Chicken Wrap :: Claude_Shannon
    EN_ROUTE :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
    DELIVERED :: #1 Sesame Chicken Wrap :: Claude_Shannon
    DELIVERED :: #2 Garlic Veggie Wrap :: Claude_Shannon
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 5 - Dropping off
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
    DELIVERED :: #1 Sesame Chicken Wrap :: Claude_Shannon
    DELIVERED :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Karen_Sparck_Jones ($100, 5 km)
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 6 - Returning
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
    DELIVERED :: #1 Sesame Chicken Wrap :: Claude_Shannon
    DELIVERED :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 6 - Returning
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
    DELIVERED :: #1 Sesame Chicken Wrap :: Claude_Shannon
    DELIVERED :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 6 - Returning

Enter command: t
******************[ Nacho-Average-Kitchen ]******************
Profit: $10
[CUSTOMERS]
  Dennis_Ritchie ($100, 2 km)
  Radia_Perlman ($100, 4 km)
  Claude_Shannon ($58, 6 km)
    DELIVERED :: #1 Sesame Chicken Wrap :: Claude_Shannon
    DELIVERED :: #2 Garlic Veggie Wrap :: Claude_Shannon
  Karen_Sparck_Jones ($100, 5 km)
  Barbara_Liskov ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Justin_Thyme
    '-O---O-' Action: 1 - Waiting

Enter command: q
Goodbye!

Input:

Carbageddon
a d Luke_Warmfood
a c Ken_Thompson 100 2
a c Margaret_Hamilton 100 4
a c Tim_Berners_Lee 100 6
a c Shafi_Goldwasser 100 7
a c Frances_Allen 100 5
a c John_von_Neumann 100 3
a c Edsger_Dijkstra 100 1
s
a o Tim_Berners_Lee CHILLI BEEF CURRY
a o Margaret_Hamilton GARLIC VEGGIE SOUP
c 2
p
t
t
t
t
t
t
t
t
t
t
t
t
a o Frances_Allen LEMON TOFU SALAD
a o Tim_Berners_Lee SESAME CHICKEN NOODLES
a o Shafi_Goldwasser GARLIC LAMB CURRY
c 3
p
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Carbageddon

Enter command: a d Luke_Warmfood
Driver 'Luke_Warmfood' added
Enter command: a c Ken_Thompson 100 2
Customer 'Ken_Thompson' added
Enter command: a c Margaret_Hamilton 100 4
Customer 'Margaret_Hamilton' added
Enter command: a c Tim_Berners_Lee 100 6
Customer 'Tim_Berners_Lee' added
Enter command: a c Shafi_Goldwasser 100 7
Customer 'Shafi_Goldwasser' added
Enter command: a c Frances_Allen 100 5
Customer 'Frances_Allen' added
Enter command: a c John_von_Neumann 100 3
Customer 'John_von_Neumann' added
Enter command: a c Edsger_Dijkstra 100 1
Customer 'Edsger_Dijkstra' added
Enter command: s
Enter command: a o Tim_Berners_Lee CHILLI BEEF CURRY
Order '#1' added: $21 item + $5 delivery
Enter command: a o Margaret_Hamilton GARLIC VEGGIE SOUP
Order '#2' added: $11 item + $5 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: p
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
  Tim_Berners_Lee ($74, 6 km)
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    READY :: #2 Garlic Veggie Soup :: Margaret_Hamilton
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
  Tim_Berners_Lee ($74, 6 km)
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 2 - Picking up
    EN_ROUTE :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    EN_ROUTE :: #2 Garlic Veggie Soup :: Margaret_Hamilton

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 3 - Departing
    EN_ROUTE :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    EN_ROUTE :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Margaret_Hamilton ($84, 4 km)
  Tim_Berners_Lee ($74, 6 km)
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    EN_ROUTE :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 5 - Dropping off
    EN_ROUTE :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Tim_Berners_Lee ($74, 6 km)
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 5 - Dropping off
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning

Enter command: t
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: a o Frances_Allen LEMON TOFU SALAD
Order '#3' added: $15 item + $5 delivery
Enter command: a o Tim_Berners_Lee SESAME CHICKEN NOODLES
Order '#4' added: $17 item + $5 delivery
Enter command: a o Shafi_Goldwasser GARLIC LAMB CURRY
Order '#5' added: $23 item + $5 delivery
Enter command: c 3
Cooked 3 order(s)
Enter command: p
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #3 Lemon Tofu Salad :: Frances_Allen
    READY :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 2 - Picking up
    EN_ROUTE :: #3 Lemon Tofu Salad :: Frances_Allen
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 3 - Departing
    EN_ROUTE :: #3 Lemon Tofu Salad :: Frances_Allen
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
  John_von_Neumann ($100, 3 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #3 Lemon Tofu Salad :: Frances_Allen
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #3 Lemon Tofu Salad :: Frances_Allen
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 5 - Dropping off
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 5 - Dropping off
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 2 - Picking up
    EN_ROUTE :: #5 Garlic Lamb Curry :: Shafi_Goldwasser

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 3 - Departing
    EN_ROUTE :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 4 - Transporting
    EN_ROUTE :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 5 - Dropping off
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning
[ORDERS]
  (no orders)
[DRIVER]
  (no driver)

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 6 - Returning

Enter command: t
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: q
Goodbye!

Input:

Carbageddon
a d Luke_Warmfood
a c Ken_Thompson 100 2
a c Margaret_Hamilton 100 4
a c Tim_Berners_Lee 100 6
a c Shafi_Goldwasser 100 7
a c Frances_Allen 100 5
a c John_von_Neumann 100 3
a c Edsger_Dijkstra 100 1
s
a o Tim_Berners_Lee CHILLI BEEF CURRY
a o Margaret_Hamilton GARLIC VEGGIE SOUP
c 2
p
f 12
a o Frances_Allen LEMON TOFU SALAD
a o Tim_Berners_Lee SESAME CHICKEN NOODLES
a o Shafi_Goldwasser GARLIC LAMB CURRY
c 3
p
f 22
q

Input and Output:

dcc --leak-check main.c cs_eats.c -o cs_eats
./cs_eats
Welcome to CS Eats!
    _____           )   ________        ___       
   (     )      )  (___/___     \  __  |" "|  __  
    |   |     _(__/_)_     \S   | |''| |'" | |""| 
    |___|    /        \S   |TS  | | "| |''"| |'"| 
    :^_^:    |   CS   |TS  |____| |"'| |" "| |" | 
   _`~^~'_   |  EATS  |____| __   ---------------
 /    ^    \ |________|   .-'--`--. - - - - - - -
 ~[$|$|$|$]~              '-O---O-' -------------

Enter a restaurant name: Carbageddon

Enter command: a d Luke_Warmfood
Driver 'Luke_Warmfood' added
Enter command: a c Ken_Thompson 100 2
Customer 'Ken_Thompson' added
Enter command: a c Margaret_Hamilton 100 4
Customer 'Margaret_Hamilton' added
Enter command: a c Tim_Berners_Lee 100 6
Customer 'Tim_Berners_Lee' added
Enter command: a c Shafi_Goldwasser 100 7
Customer 'Shafi_Goldwasser' added
Enter command: a c Frances_Allen 100 5
Customer 'Frances_Allen' added
Enter command: a c John_von_Neumann 100 3
Customer 'John_von_Neumann' added
Enter command: a c Edsger_Dijkstra 100 1
Customer 'Edsger_Dijkstra' added
Enter command: s
Enter command: a o Tim_Berners_Lee CHILLI BEEF CURRY
Order '#1' added: $21 item + $5 delivery
Enter command: a o Margaret_Hamilton GARLIC VEGGIE SOUP
Order '#2' added: $11 item + $5 delivery
Enter command: c 2
Cooked 2 order(s)
Enter command: p
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
  Tim_Berners_Lee ($74, 6 km)
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    READY :: #2 Garlic Veggie Soup :: Margaret_Hamilton
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: f 12
******************[ Carbageddon ]******************
Profit: $11
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($74, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($100, 7 km)
  Frances_Allen ($100, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: a o Frances_Allen LEMON TOFU SALAD
Order '#3' added: $15 item + $5 delivery
Enter command: a o Tim_Berners_Lee SESAME CHICKEN NOODLES
Order '#4' added: $17 item + $5 delivery
Enter command: a o Shafi_Goldwasser GARLIC LAMB CURRY
Order '#5' added: $23 item + $5 delivery
Enter command: c 3
Cooked 3 order(s)
Enter command: p
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
  Frances_Allen ($80, 5 km)
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
    READY :: #3 Lemon Tofu Salad :: Frances_Allen
    READY :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
    READY :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: f 22
******************[ Carbageddon ]******************
Profit: $33
[CUSTOMERS]
  Ken_Thompson ($100, 2 km)
  Margaret_Hamilton ($84, 4 km)
    DELIVERED :: #2 Garlic Veggie Soup :: Margaret_Hamilton
  Tim_Berners_Lee ($52, 6 km)
    DELIVERED :: #1 Chilli Beef Curry :: Tim_Berners_Lee
    DELIVERED :: #4 Sesame Chicken Noodles :: Tim_Berners_Lee
  Shafi_Goldwasser ($72, 7 km)
    DELIVERED :: #5 Garlic Lamb Curry :: Shafi_Goldwasser
  Frances_Allen ($80, 5 km)
    DELIVERED :: #3 Lemon Tofu Salad :: Frances_Allen
  John_von_Neumann ($100, 3 km)
  Edsger_Dijkstra ($100, 1 km)
[ORDERS]
  (no orders)
[DRIVER]
       __
    .-'--`--. Driver: Luke_Warmfood
    '-O---O-' Action: 1 - Waiting

Enter command: q
Goodbye!

Clarifications

  • [name] is a string with length less than MAX_SIZE and will not contain spaces.
  • If the driver is located at customer that is moved with a sort customers s command, then the driver moves with the customer.
  • [n] is a positive integer.
  • This stage should not affect the Stage 2.5 Deliver Orders command. The d command should function as normal.

The following cases will not be tested:

  • Using a simulate turn t command when the driver does not exist.
  • Delivering an EN_ROUTE order with the deliver orders d command.
  • Deleting an EN_ROUTE order.
  • Deleting customers after the driver has been added to the restaurant.
  • Merging customers after the driver has been added to the restaurant.

Testing and Submission

Remember to do your own testing! Are you finished with this stage? If so, you should make sure to do the following:
  • Run 1511 style and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style and readability!
  • Autotest for this stage of the assignment by running the autotest-stage command as shown below.
  • Remember -- give early and give often. Only your last submission counts, but why not be safe and submit right now?
1511 style cs_eats.c
1511 style cs_eats.h
1511 style main.c
1511 autotest-stage 04 cs_eats
give cs1511 ass2_cs_eats cs_eats.c cs_eats.h main.c

Extension

As an extension, we have set up a starting point to add a texture pack to your program via SplashKit.

Extension activities are NOT worth any marks, nor are there any autotests. They are just for fun!

Getting Started

To get started with SplashKit, complete the SplashKit activities.

Sample Code

First, navigate to your SplashKit directory.

cd splashkit

Create a new directory for your project and cd into it.

mkdir cs_eats
cd cs_eats

Set up your directory for SplashKit with:

1511 setup-splashkit-directory

Run this cp command to retrieve the sample code.

cp -n /web/cs1511/25T2/activities/cs_eats/splashkit_example.c .

This should add the splashkit_example.c sample code to your current directory.

Check that SplashKit Works

Let's check that SplashKit works by running a test file. It should display a white square with a grid inside.

skm clang++ splashkit_example.c -o splashkit_example
./splashkit_example

Have a look inside of splashkit_example.c and note that:

  • At the very top, the the SplashKit library "splashkit.h" is included. If you see an error here, check SplashKit #1 - Getting Started for a solution to set up your VS Code project.
  • In the main() function:
    • open_window("SplashKit Example", 600, 400) creates a 600×400 window for displaying graphics.
    • The while (!window_close_requested(w)) loop keeps running until the user closes the window. Within this loop:
      • process_events() handles input or window-related actions (like closing the window).
      • refresh_screen() updates the window so any graphical changes (like drawing a rectangle) are displayed to the user.

Running Your SplashKit Code

When creating your SplashKit program, give it a distinctive name like splashkit_cs_eats.c.

To compile and run your program, use:

skm clang++ splashkit_cs_eats.c -o splashkit_cs_eats
./splashkit_cs_eats

Writing Your SplashKit Program

Now that you've seen how the sample code works, it’s time to create your own SplashKit program.

If you're not sure where to begin, start by researching the SplashKit Library. The goal at first is not to understand and memorise the entire library. Rather, it's better to skim through the pages to build a broad understanding of the capabilities that SplashKit can bring to your creations.

The Graphics page is a good place to start, and the following sections will be useful:

  • Windows for opening, closing, and controlling the size of windows.
  • Color for using different colours.
  • Graphics for drawing shapes, images, and text.
  • Geometry for handling shapes such as rectangles, circles, lines, and points.
  • Input for capturing and handling user input such as keyboard and mouse events.

SplashKit Gallery

Have you built something fun or interesting using SplashKit? Show it off and inspire your classmates!

Share any screenshots or short videos of your running program in the SplashKit Gallery on the Course Forum. Feel free to add a brief description or reflect on how you made it, so we can all learn from your mistakes journey 😅.

Tools

Creating Restaurants in Separate Files

If you are getting sick of typing your inputs every time you run CS Eats, you might want to store your input in a separate file.

1. Create a file for your input.

First, let's create a file to store in the input for a restaurant that you have created. This isn't a .c file, it's just a regular plain text file, the file extension .in works nicely for this!

Let's put it in the same directory as your assignment code.

cd ass2
ls
cs_eats.c 
cs_eats.h
main.c
cs_eats
my_restaurant.in

2. Add your input to the file

Inside of this file, add the input for the restaurant.

Your file could look a bit like this (including the newline at the end):

a c Sofia 50 20
a c Ibby 50 30
a c Grace 50 10
a o Sofia LEMON CHICKEN NOODLES
a o Ibby SESAME BEEF WRAP
a o Grace GARLIC VEGGIE CURRY
p

3. Run the code with your file

Next, instead of just running ./cs_eats, lets tell the computer to first read from the file we created.

cat my_restaurant.in - | ./cs_eats

This will also work on the reference implementation too!

cat my_restaurant.in - | 1511 cs_eats




Assessment

Assignment Conditions

  • Joint work is not permitted on this assignment.

    This is an individual assignment.

    The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not permitted.

    The only exception being if you use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such as Stack Overflow or other publicly available resources. You should attribute the source of this code clearly in an accompanying comment.

    Assignment submissions will be examined, both automatically and manually for work written by others.

    Do not request help from anyone other than the teaching staff of COMP1511.

    Do not post your assignment code to the course forum - the teaching staff can view assignment code you have recently autotested or submitted with give.

    Rationale: this assignment is an individual piece of work. It is designed to develop the skills needed to produce an entire working program. Using code written by or taken from other people will stop you learning these skills.

  • The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment.

    The use of Generative AI to generate code solutions is not permitted on this assignment.

    Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you learning these fundamental concepts.

  • Sharing, publishing, distributing your assignment work is not permitted.

    Do not provide or show your assignment work to any other person, other than the teaching staff of COMP1511. For example, do not share your work with friends.

    Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository.

    Rationale: by publishing or sharing your work you are facilitating other students to use your work, which is not permitted. If they submit your work, you may become involved in an academic integrity investigation.

  • Sharing, publishing, distributing your assignment work after the completion of COMP1511 is not permitted.

    For example, do not place your assignment in a public GitHub repository after COMP1511 is over.

    Rationale:COMP1511 sometimes reuses assignment themes, using similar concepts and content. If students in future terms can find your code and use it, which is not permitted, you may become involved in an academic integrity investigation.

Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of 0 in COMP1511 and exclusion from UNSW.

Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted - you may be penalised, even if the work was submitted without your knowledge or consent. This may apply even if your work is submitted by a third party unknown to you.

If you have not shared your assignment, you will not be penalised if your work is taken without your consent or knowledge.

For more information, read the UNSW Student Code , or contact the course account. The following penalties apply to your total mark for plagiarism:

0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignment Submitting any other person's work. This includes joint work.
0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent.

Submission of Work

You should submit intermediate versions of your assignment. Every time you autotest or submit, a copy will be saved as a backup. You can find those backups  here , by logging in, and choosing the yellow button next to ass2_cs_eats.

Every time you work on the assignment and make some progress, you should copy your work to your CSE account and submit it using the give  command below.

It is fine if intermediate versions do not compile or otherwise fail submission tests.

Only the final submitted version of your assignment will be marked.

You submit your work like this:

  give cs1511 ass2_cs_eats cs_eats.c cs_eats.h main.c

Assessment Scheme

This assignment will contribute 25% to your final mark.

80% of the marks for this assignment will be based on the performance of the code you write in cs_eats.c cs_eats.h main.c.

20% of the marks for this assignment will come from manual marking of the readability of the C you have written. The manual marking will involve checking your code for clarity, and readability, which includes the use of functions and efficient use of loops and if statements.

Marks for your performance will be allocated roughly according to the below scheme.

COMP1911

100% for Performance Completely Working Implementation, which exactly follows the specification (Stage 1, 2 and 3.3).
85% for Performance Completely Working implementation of Stage 1 and Stage 2.
40% for Performance Completely Working implementation of Stage 1.

COMP1511

100% for Performance Completely Working Implementation, which exactly follows the specification (Stage 1, 2, 3 and 4).
85% for Performance Completely working implementation of Stage 1, 2 and 3.
65% for Performance Completely working implementation of Stage 1 and Stage 2.
35% for Performance Completely working implementation of Stage 1.

Marks for your style will be allocated roughly according to the scheme below.

Style Marking Rubric

0 1 2 3 4
Formatting (/5)
Indentation (/2) - Should use a consistent indentation scheme. Multiple instances throughout code of inconsistent/bad indentation Code is mostly correctly indented Code is consistently indented throughout the program
Whitespace (/1) - Should use consistent whitespace (for example, 3 + 3 not 3+ 3) Many whitespace errors No whitespace errors
Vertical Whitespace (/1) - Should use consistent whitespace (for example, vertical whitespace between sections of code) Code has no consideration for use of vertical whitespace Code consistently uses reasonable vertical whitespace
Line Length (/1) - Lines should be max. 80 characters long Many lines over 80 characters No lines over 80 characters
Documentation (/5)
Comments (incl. header comment) (/3) - Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included No comments provided throughout code Few comments provided throughout code Comments are provided as needed, but some details or explanations may be missing causing the code to be difficult to follow Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included
Function/variable/constant naming (/2) - Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code Functions/variables/constants names do not follow naming conventions in style guide and help in understanding the code Functions/variables/constants names somewhat follow naming conventions in style guide and help in understanding the code Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code
Organisation (/5)
Function Usage (/4) - Code has been decomposed into appropriate functions separating functionalities No functions are present, code is one main function Some code has been moved to functions Some code has been moved to sensible/thought out functions, and/or many functions exceed 50 lines (incl. main function) Most code has been moved to sensible/thought out functions, and/or some functions exceed 50 lines (incl. main function) All code has been meaningfully decomposed into functions of a maximum of 50 lines (incl. The main function)
Function Prototypes (/1) - Function Prototypes have been used to declare functions above main Functions are used but have not been prototyped All functions have a prototype above the main function or no functions are used
Elegance (/5)
Overdeep nesting (/2) - You should not have too many levels of nesting in your code (nesting which is 5 or more levels deep) Many instances of overdeep nesting <= 3 instances of overdeep nesting No instances of overdeep nesting
Code Repetition (/2) - Potential repetition of code has been dealt with via the use of functions or loops Many instances of repeated code sections <= 3 instances of repeated code sections Potential repetition of code has been dealt with via the use of functions or loops
Constant Usage (/1) - Any magic numbers are #defined None of the constants used throughout program are #defined All constants used are #defined and are used consistently in the code
Illegal elements
Illegal elements - Presence of any illegal elements indicated in the style guide CAP MARK AT 16/20

Note that the following penalties apply to your total mark for plagiarism:

0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignment Submitting any other person's work. This includes joint work.
0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent.

Allowed C Features

This assignment must be implemented exclusively using linked lists for all core data structures and logic. Other than arrays, there are no restrictions on C features in this assignment, except for those outlined in the Style Guide. If you choose to use features beyond what has been taught in COMP1511/1911, be aware that course staff may not be able to assist you.

Due Date

This assignment is due 08 August 2025 17:00:00. For each day after that time, the maximum mark it can achieve will be reduced by 5% (off the ceiling).
  • For instance, at 1 day past the due date, the maximum mark you can get is 95%.
  • For instance, at 3 days past the due date, the maximum mark you can get is 85%.
  • For instance, at 5 days past the due date, the maximum mark you can get is 75%.
No submissions will be accepted after 5 days late, unless you have special provisions in place.

Change Log

Version 0.0
(2025-07-18 09:00)
  • Assignment Released