Code Monkey home page Code Monkey logo

subway-machine-prolog's Introduction

Subway_Machine_Prolog

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.

Introduction

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:

  1. If the person chose a veggie meal, meat options should not be offered.
  2. If a person chose a healthy meal, fatty sauces should not be offered.
  3. If a person chose a vegan meal, cheese top-up should not be offered.
  4. 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
  • top-up
    • cheese_topup
      • processed_cheddar, monterey_cheddar
    • non_cheese_topup
      • egg_mayo, guacamole]
  • sides
    • chips, cookies, hash_browns, yogurt, drinks

Demo

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).

Test case 1: Standard Meal

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:

Test case 2: Value Meal

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.

Test case 3: Veggie Meal

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.

Test case 4: Vegan 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.

Test case 5: Healthy Meal

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

The results are shown as below:

subway-machine-prolog's People

Contributors

stephaniemussi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.