organization-code 0.1.0

Online store library
Documentation
pub use category::Category;

#[derive(PartialEq, Debug)]
pub struct Product {
    id: u64,
  pub  name: String,
    price: f64,
    category: Category,
}

pub mod category;
///! # Online Business
impl Product {
    fn calculate_tax(&self) -> f64 {
        self.price * 0.1
    }

    pub fn product_price(&self) -> f64 {
        self.price + self.calculate_tax()
    }
    /// # Example
    /// ```
    /// use organization_code::Category;
    /// use organization_code::Product;
    /// let some_product : Product = Product::new(1,String::from("Laptop"),799.99,Category::Electonics);
    /// assert_eq!(some_product.name,String::from("Laptop"));
    /// ```
    pub fn new(id: u64, name: String, price: f64, category: Category) -> Self {
        Product {
            id,
            name,
            price,
            category,
        }
    }

    pub fn display_product_info(&self) {
        println!("id : {:?} , name : {:?} , category : {:?}, price : {:?}",
                 self.id,
                 self.name,
                 "Electronics",
                 self.price
        )
    }
}