The Prolog Subway Sandwich Machine offers users different options of meals and display the menu based on user's choice. The machine is also capable of recording the order and displaying the receipt.
The machine offers the following options:
- meal options
- bread options
- meat options
- vegetable options
- sauce options
- top-up options
- sides options
Moreover, the machine can intelligently display the options selectively person’s previous choices:
- If the person chose a veggie meal, meat options should not be offered.
- If a person chose a healthy meal, fatty sauces should not be offered.
- If a person chose a vegan meal, cheese top-up should not be offered.
- If a person chose a value meal, no top-up should be offered.
Based on the requirements above, the working sequence is designed in the following way:
The full menu is as followed:
- meal
- standard, value, veggie, vegan, healthy
- bread
- italian_wheat, hearty_italian, honey_oat, parmesan_oregano, multigrain, flatbread
- meat
- chicken_breast, ham, bacon, meat_ball, roast_beef, steak, tuna
- veggies
- cucumbers, bell_peppers, lettuce, onions, tomatoes, olives, corn, pickles
- sauce
- fatty_sauce
- chipotle_southwest, ranch, bbq, mayonnaise, mustard
- non_fatty_sauce
- chilli_sauce, tomato_sauce
- fatty_sauce
- top-up
- cheese_topup
- processed_cheddar, monterey_cheddar
- non_cheese_topup
- egg_mayo, guacamole]
- cheese_topup
- sides
- chips, cookies, hash_browns, yogurt, drinks
After implementing the machine, the following test cases are used to demonstrate the fulfillment of all requirements.
The first thing before the testing is to declare the list of user's choices as "dynamic". This allows SWI-Prolog to modify the lists on the fly.
Dynamicall(0):- dynamic(chosen_meal/1),
dynamic(chosen_bread/1),
dynamic(chosen_meat/1),
dynamic(chosen_veggies/1),
dynamic(chosen_sauce/1),
dynamic(chosen_topup/1),
dynamic(chosen_sides/1).
The choices are listed as below:
- Meal: Standard
- Bread: Parmesan Oregano
- Meat: Roast Beef
- Veggies: Cucumbers, Pickles, Olives
- Sauce: Ranch, BBQ
- Top-up: Processed Cheddar
- Sides: Cookies, Drinks
The results are shown as below:
The choices are listed as below:
- Meal: Value
- Bread: Italian Wheat
- Meat: Tuna
- Veggies: Lettuce, Bell Peppers
- Sauce: Chipotle Southwest
- Sides: Yogurt
The results are shown as below:
It can be seen that top-up never appears in the ordering steps.
The choices are listed as below:
- Meal: Veggie
- Bread: Multigrain
- Veggies: Pickles, Lettuce
- Sauce: Chilli Sauce, Mustard
- Top-up: Egg Mayo
- Sides: Drinks, Hash Browns
The results are shown as below:
It is shown above that meat never appears for the user who chooses veggie meal.
The choices are listed as below:
- Meal: Vegan
- Bread: Flatbread
- Veggies: Corn, Onions, Tomatoes, Lettuce
- Sauce: Chilli Sauce
- Top-up: Gaucamole
- Sides: (none)
The results are shown as below:
As it can be seen, the only non-cheese top-up is displayed, and meat never appears.
The choices are listed as below:
- Meal: Healthy
- Bread: Honey Oat
- Meat: Chicken Breast
- Veggies: Onions, Pickles, CUcumber
- Sauce: Tomato Sauce
- Top-up: Moneterey Cheddar
- Sides: Yogurt