pub struct Order {
pub order: Items,
pub menu_items: Items,
pub cost_for_items: Items,
}
Fields§
§order: Items
§cost_for_items: Items
Implementations§
Source§impl Order
impl Order
Sourcepub fn order_add(&mut self, item_name: String) -> Result<(), &'static str>
pub fn order_add(&mut self, item_name: String) -> Result<(), &'static str>
§Add To The Order
§Example
use map_macro::hash_map;
use std::collections::HashMap;
use dit_as_91896::{
order::Order,
food::Items
};
let menu = Items::new(
hash_map! {
String::from("test_food") => 2.0
},
HashMap::new(),
HashMap::new()
);
let cost_menu = Items::new(
hash_map! {
String::from("test_food") => 1.0
},
HashMap::new(),
HashMap::new()
);
let mut my_order: Order = Order::new(
menu,
cost_menu
);
// adds two of the food.
my_order.order_add(String::from("test_food")).unwrap();
my_order.order_add(String::from("test_food")).unwrap();
let order_output = Items::new(hash_map! { String::from("test_food") => 4.0 }, HashMap::new(), HashMap::new());
assert!(my_order.order.food == order_output.food);
assert!(my_order.order.drinks == order_output.drinks);
assert!(my_order.order.sides == order_output.sides);
Sourcepub fn cost_profit(&self) -> Vec<f64>
pub fn cost_profit(&self) -> Vec<f64>
§Calculate the Cost and profit.
Find for the Customer and the profit for the store.\
Returns:
Vec
§Example
use map_macro::hash_map;
use std::collections::HashMap;
use dit_as_91896::{
order::Order,
food::Items
};
// cost to user
let menu = Items::new(
hash_map! {
String::from("test_food") => 2.0
},
HashMap::new(),
HashMap::new()
);
// cost of items for eg "the store"
let cost_menu = Items::new(
hash_map! {
String::from("test_food") => 1.0
},
HashMap::new(),
HashMap::new()
);
let mut my_order: Order = Order::new(
menu,
cost_menu
);
// adds two of the food.
my_order.order_add(String::from("test_food")).unwrap();
my_order.order_add(String::from("test_food")).unwrap();
assert!(my_order.cost_profit() == vec![4.0, 2.0]);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Order
impl RefUnwindSafe for Order
impl Send for Order
impl Sync for Order
impl Unpin for Order
impl UnwindSafe for Order
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more