Add Non user class definitions
This commit is contained in:
@@ -1 +1,16 @@
|
||||
/*
|
||||
Author: Joel Mathew Thomas
|
||||
Date: 18-02-2026
|
||||
*/
|
||||
|
||||
#include "Item.h"
|
||||
|
||||
int Item::getQuantity() const
|
||||
{
|
||||
return m_quantity;
|
||||
}
|
||||
|
||||
MenuItem& Item::getMenuItem()
|
||||
{
|
||||
return m_item;
|
||||
}
|
||||
|
||||
@@ -1 +1,32 @@
|
||||
/*
|
||||
Author: Joel Mathew Thomas
|
||||
Date: 18-02-2026
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include "MenuItem.h"
|
||||
|
||||
int MenuItem::getId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
}
|
||||
|
||||
std::string MenuItem::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
double MenuItem::getPrice() const
|
||||
{
|
||||
return m_price;
|
||||
}
|
||||
|
||||
void MenuItem::setPrice(double price)
|
||||
{
|
||||
if (price <= 0)
|
||||
{
|
||||
throw std::runtime_error("Invalid Price for MenuItem");
|
||||
}
|
||||
m_price = price;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public:
|
||||
int getId() const;
|
||||
std::string getName() const;
|
||||
std::string getDescription() const;
|
||||
void setDescription(const std::string&);
|
||||
double getPrice() const;
|
||||
void setPrice(double);
|
||||
};
|
||||
|
||||
@@ -1 +1,26 @@
|
||||
#include "Order.h"
|
||||
|
||||
int Order::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Order::addItem(const Item& item)
|
||||
{
|
||||
m_items.push_back(std::make_shared<Item>(item));
|
||||
}
|
||||
|
||||
items& Order::getItems()
|
||||
{
|
||||
return m_items;
|
||||
}
|
||||
|
||||
double Order::getTotal() const
|
||||
{
|
||||
double total = 0;
|
||||
for (auto& itemPointer : m_items)
|
||||
{
|
||||
total += itemPointer->getMenuItem().getPrice();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,10 @@ Date: 18-12-2026
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "Item.h"
|
||||
|
||||
using items = std::vector<Item>;
|
||||
using items = std::vector<std::shared_ptr<Item>>;
|
||||
|
||||
enum class OrderStatus
|
||||
{
|
||||
@@ -36,10 +37,8 @@ public:
|
||||
m_totalAmount(0),
|
||||
m_status(OrderStatus::CREATED)
|
||||
{}
|
||||
~Order();
|
||||
int getId() const;
|
||||
void addItem();
|
||||
void removeItem();
|
||||
void addItem(const Item&);
|
||||
items& getItems();
|
||||
double getTotal() const;
|
||||
};
|
||||
|
||||
@@ -1 +1,31 @@
|
||||
/*
|
||||
Author: Joel Mathew Thomas
|
||||
Date: 18-02-2026
|
||||
*/
|
||||
|
||||
#include "Restaurant.h"
|
||||
|
||||
int Restaurant::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
menuItems& Restaurant::getMenuItems()
|
||||
{
|
||||
return m_menuItems;
|
||||
}
|
||||
|
||||
orders& Restaurant::getOrders()
|
||||
{
|
||||
return m_orders;
|
||||
}
|
||||
|
||||
bool Restaurant::getStatus() const
|
||||
{
|
||||
return m_isOpen;
|
||||
}
|
||||
|
||||
void Restaurant::setStatus(bool status)
|
||||
{
|
||||
m_isOpen = status;
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ Date: 18-12-2026
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "MenuItem.h"
|
||||
#include "Order.h"
|
||||
|
||||
using menuItems = std::vector<MenuItem>;
|
||||
using orders = std::vector<Order*>;
|
||||
using menuItems = std::map<int, std::shared_ptr<MenuItem>>;
|
||||
using orders= std::map<int, std::shared_ptr<Order>>;
|
||||
|
||||
class Restaurant
|
||||
{
|
||||
@@ -19,23 +20,21 @@ private:
|
||||
std::string m_name;
|
||||
menuItems m_menuItems;
|
||||
orders m_orders;
|
||||
bool m_status;
|
||||
bool m_isOpen;
|
||||
public:
|
||||
Restaurant() :
|
||||
m_id(0),
|
||||
m_name(""),
|
||||
m_status(true)
|
||||
m_isOpen(true)
|
||||
{}
|
||||
Restaurant(int id, const std::string& name) :
|
||||
m_id(id),
|
||||
m_name(name),
|
||||
m_status(true)
|
||||
m_isOpen(true)
|
||||
{}
|
||||
~Restaurant();
|
||||
int getId() const;
|
||||
menuItems& getMenuItems();
|
||||
orders& getOrders();
|
||||
bool getStatus() const;
|
||||
void setStatus(bool);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user