Question
need help in my project it is about a restaurant system the code should be written in prolog language (fact , rules , query) Description:
need help in my project it is about a restaurant system the code should be written in prolog language (fact , rules , query)
Description:
what we want to do is a small expert system of a restaurant that enable the user to order by asking him ordinary questions
the idea of the program depends on providing a varied list of good fast food meals. for example. burger meals and pizza meals for the user, in addition, providing a feature for making suggestions which recommends a meal to user based on user preferences. such as the system will ask the user some questions and based on the user answers the system will suggest to the user a meal. Such as a query that ask the user the same ordinary question we heard when we order from any restaurant also suggest a meal based on the user choices .
******I need at least 8 queries*********
i wrote this code but it has an error i don't know where is the problem i need fixing for my code
% Define facts for food options
food_type(burger).
food_type(pizza).
topping(cheese).
topping(mushrooms).
topping(onions).
topping(pepperoni).
size(small).
size(medium).
size(large).
side(fries).
side(salad).
side(onion_rings).
substitution(no).
substitution(yes).
drink(no).
drink(yes).
dessert(no).
dessert(yes).
% Define rules for meal suggestions
suggest_meal(FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert, Meal) :-
food_type(FoodType),
member(Toppings, [cheese, mushrooms, onions, pepperoni]),
size(Size),
member(Sides, [fries, salad, onion_rings]),
substitution(Substitutions),
drink(Drink),
dessert(Dessert),
Meal = "Special " + FoodType + " with " + Toppings + ", " + Size + " size, " + Sides + ", " + Substitutions + " substitutions, " + Drink + " drink, and " + Dessert + " dessert.".
% Define queries for user input
ask_food_type :-
write("What type of food would you like to order? (burger/pizza)"),
read(FoodType),
assert(food_type(FoodType)).
ask_toppings :-
write("Would you like to add any toppings? (yeso)"),
read(Toppings),
assert(topping(Toppings)).
ask_size :-
write("What size would you like your meal to be? (small/medium/large)"),
read(Size),
assert(size(Size)).
ask_sides :-
write("Would you like any sides with your meal? (fries/salad/onion rings)"),
read(Sides),
assert(side(Sides)).
ask_substitutions :-
write("Would you like to make any substitutions in your meal? (yeso)"),
read(Substitutions),
assert(substitution(Substitutions)).
ask_drink :-
write("Would you like to add a drink to your order? (yeso)"),
read(Drink),
assert(drink(Drink)).
ask_dessert :-
write("Would you like to add a dessert to your order? (yeso)"),
read(Dessert),
assert(dessert(Dessert)).
% Suggest meal based on user input
suggest_order :-
ask_food_type,
ask_toppings,
ask_size,
ask_sides,
ask_substitutions,
ask_drink,
ask_dessert,
suggest_meal(FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert, Meal),
write("Based on your choices, we suggest the following meal: "),
write(Meal), nl,
write("Would you like to order this meal? (yeso)"),
read(Order),
(
(Order == yes)
-> write("Thank you for your order!")
; write("Okay, let's try again.")
).
SWISH File Edit v Examples v Help v Singleton variables: [FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert] ic Singleton variables: [FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert] ask_dessert, [3] assert(food_type(pizza)) suggest_meal(FoodType, Toppings, Size, Sides, Substitutions, Drink, Des [1] suggest_order at if line 76 write("Would you like to order this meal? (yeso)"), ?- suggest_order
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started