This Prolog code implements a customer order management system using Prolog predicates. It includes functionalities such as listing orders, counting orders, getting items in an order, calculating order prices, boycotting items or companies, removing boycott items from an order, calculating price differences between items and their alternatives, and allowing for the insertion and removal of items, alternatives, and boycott companies from the knowledge base.
The assignment requires the use of a data file named data.pl
, which contains facts about customers, items, orders, boycotted companies, and alternatives.
customer(CustID, CustUserName).
item(ItemName, CompanyName, Price).
order(CustID, OrderID, [Items]).
boycott_company(CompanyName, Justification).
alternative(ItemName, AlternativeItem).
- Lists all orders of a specific customer. Example:
?- list_orders(shahd_ghazal2002, Orders).
- Gets the number of orders of a specific customer given their ID Example:
?- countOrdersOfCustomer(101, Count).
- Lists all items in a specific customer order given the customer ID and order ID. Example:
?- getItemsInOrderById(101, 1, Items).
- Gets the number of items in a specific customer order given the customer name and order ID. Example:
?- getNumOfItems(shahd_ghazal2002, 2, Count).
- Calculates the price of a given order given the customer name and order ID. Example:
?- calcPriceOfOrder(shahd_ghazal2002, 2, TotalPrice).
- Determines whether to boycott an item or company. Example:
?- isBoycott(sunbites).
- Provides the justification for boycotting a specific item or company. Example:
?- whyToBoycott(dasani, Justification).
- Removes all the boycott items from a specific order given the username and order ID. Example:
?- removeBoycottItemsFromAnOrder(abu_juliaa, 1, NewList).
- Calculates the price difference between a boycott item and its alternative. Example:
?- getTheDifferenceInPriceBetweenItemAndAlternative(lipton, Alternative, DiffPrice).
- allowing insertion and removal of items, alternatives, and boycott companies from the knowledge base. Examples:
?- add_item(alpella_wafer, 'Alpella', 4).
?- item(alpella_wafer, 'Alpella', 4).
?- remove_item(alpella_wafer, 'Alpella', 4).
?- item(alpella_wafer, 'Alpella', 4).
This project is licensed under the [MIT] License - see the LICENSE.md file for details.