/*---
    get_waffle_order example from 
       LA-run Final Exam Review in 9:00 am
       CS 111 - Week 15 Lab

    presented by: Kai Frimodig
    adapted by:   Sharon Tuttle
    last modified: 2025-12-12
---*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

// signature: get_waffle_order: string[] int -> string

// purpose: expects array of waffle toppings, and the size of array
//          and has the side-effect of prompting the user to give the toppings
//          that they want
//          and returns a string that is the list of waffle toppings that the user wanted

/* tests:
        string holiday_toppings[3] = {"gummy bears", "oreos", "sprinkles"};

        if, when called as below, the user answers y or n to each topping when prompted to,
	and if they said y to all then:
	
	get_waffle_order(holiday_toppings, 3) ==
	    "waffle + gummy bears + oreos + sprinkles"
	    
        string weekend_toppings[4] = {"choc chip", "sprinkles", "marshmallows", whipped cream"};

        if, when called as below, the user answers y or n to each topping when prompted to,
        and if they answer y to the 1st and 3rd topping only, then:

        get_waffle_order(weekend_toppings, 4) == 
            "waffle + choc chip + marshmallows"

*/

string get_waffle_order(string toppings[], int toppings_amt)
{
    string waffle_order = "waffle";

    char user_response;

    // ask user if they would like each of the available toppings

    cout << "would you like this topping: " << endl;

    for (int i = 0; i < toppings_amt; ++i)
    {
        cout << toppings[i] << "?" << endl;
        cout << "(type y for yes or n for no)" << endl;
        cin >> user_response;

        if (user_response == 'y')
        {
            waffle_order = waffle_order + " + " + toppings[i];
        }
    }

    return waffle_order;
}

/*---
    test the function above
---*/

int main()
{
    cout << boolalpha;

    string holiday_toppings[3] = {"gummy bears", "oreos", "sprinkles"};
    string weekend_toppings[4] = {"choc chip", "sprinkles", "marshmallows",
                                  "whipped cream"};

    cout << endl;
    cout << "*** Testing: get_waffle_order ***" << endl;

    cout << endl;
    cout << "==========" << endl;
    cout << "For this test, please answer y for each topping. " << endl
         << "   Test passes if you see true, then a waffle order with" << endl
         << "   gummy bears, oreos, and sprinkles: " << endl;
    cout << "==========" << endl;

    string their_order = get_waffle_order(holiday_toppings, 3);
    cout << endl;
    cout << (their_order == "waffle + gummy bears + oreos + sprinkles") << endl;
    cout << their_order << endl;
    
    cout << endl;
    cout << "==========" << endl;
    cout << "For this test, please answer y for just choc chip and marshmallows. " << endl
         << "   Test passes if you see true, then a waffle order with" << endl
         << "   just choc chip and marshmallows" << endl;
    cout << "==========" << endl;
    
    their_order = get_waffle_order(weekend_toppings, 4);
    cout << endl;
    cout << (their_order == "waffle + choc chip + marshmallows") << endl;
    cout << their_order << endl;

    cout << endl;
    return EXIT_SUCCESS;
}