rust_pizzeria
Intro:
we are creating a software system for a pizza restaurant, one of the modules is supposed to handle the management of various pizza recipes and how the orders are put together, and a big part of the module will be the control of food types, the potential allergens in recipes, and calories counting.
Requirements:
you are commissioned to write a data-model API (classes, interfaces, etc) which will then be used by the entire module to exchange the data about the recipes, ingredients, and all that. And also couple helper function that demonstrate the usage of your data-model.
Tasks:
Create a data-model to represent pizza ingredients and pizza recipes, including the food types and allergens. Create a function hasAlle rgens where we can pass a certain pizza recipe and an array of allergens and receive true if the recipe contains any of the allergens. Create a function hasFoodTypes where we can pass a certain pizza recipe and an array of food types and receive true if this recipe contains any of the food types. Create functions removeAllergens and removeFoodTypes with similar parameters but they should return the same pizza recipe but with the allergens and food types removed. Create function removeIngredients where we can pass a certain pizza recipe and an array of ingredients and receive the pizza recipe without the specified ingredients. Create function doubleIngredients with the same parameters but it returns the recipe with the specified ingredients in double amount. Create function getCalories where we can pass a certain pizza recipe and it will return the number of total calories in that recipe.
Example of usage for the functions:
hasFoodTypes
when user checks they want to only see pizza with mushroomshasAllergens
when user wants to highlight any pizzas that might contain soy in itremoveIngredients
when user checks they don’t want Jalapeño pepperdoubleIngredients
when user checks they want double cheeseremoveFoodTypes
when user wants to check what the selected pizza will look like with no meatgetCalories
when user wants to check what the number will be for the resulting recipe
Setting up
If you do not have the Rust toolchain installed, please follow instructions here: Install Rust
After cloning the repo, make sure you have the Rust toolchain installed with rustc --version
and cargo --version
The following output is expected:
> rustc --version
rustc 1.55.0 (c8dfcfe04 2021-09-06)
> cargo --version
cargo 1.55.0 (32da73ab1 2021-08-23)
Running tests
cargo test
Running the program
cargo run