Add Non user class definitions
This commit is contained in:
@@ -1 +1,16 @@
|
|||||||
|
/*
|
||||||
|
Author: Joel Mathew Thomas
|
||||||
|
Date: 18-02-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Item.h"
|
#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"
|
#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;
|
int getId() const;
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
std::string getDescription() const;
|
std::string getDescription() const;
|
||||||
void setDescription(const std::string&);
|
|
||||||
double getPrice() const;
|
double getPrice() const;
|
||||||
void setPrice(double);
|
void setPrice(double);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,26 @@
|
|||||||
#include "Order.h"
|
#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
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
|
|
||||||
using items = std::vector<Item>;
|
using items = std::vector<std::shared_ptr<Item>>;
|
||||||
|
|
||||||
enum class OrderStatus
|
enum class OrderStatus
|
||||||
{
|
{
|
||||||
@@ -36,10 +37,8 @@ public:
|
|||||||
m_totalAmount(0),
|
m_totalAmount(0),
|
||||||
m_status(OrderStatus::CREATED)
|
m_status(OrderStatus::CREATED)
|
||||||
{}
|
{}
|
||||||
~Order();
|
|
||||||
int getId() const;
|
int getId() const;
|
||||||
void addItem();
|
void addItem(const Item&);
|
||||||
void removeItem();
|
|
||||||
items& getItems();
|
items& getItems();
|
||||||
double getTotal() const;
|
double getTotal() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Author: Joel Mathew Thomas
|
||||||
|
Date: 18-02-2026
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Restaurant.h"
|
#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
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include "MenuItem.h"
|
#include "MenuItem.h"
|
||||||
#include "Order.h"
|
#include "Order.h"
|
||||||
|
|
||||||
using menuItems = std::vector<MenuItem>;
|
using menuItems = std::map<int, std::shared_ptr<MenuItem>>;
|
||||||
using orders = std::vector<Order*>;
|
using orders= std::map<int, std::shared_ptr<Order>>;
|
||||||
|
|
||||||
class Restaurant
|
class Restaurant
|
||||||
{
|
{
|
||||||
@@ -19,23 +20,21 @@ private:
|
|||||||
std::string m_name;
|
std::string m_name;
|
||||||
menuItems m_menuItems;
|
menuItems m_menuItems;
|
||||||
orders m_orders;
|
orders m_orders;
|
||||||
bool m_status;
|
bool m_isOpen;
|
||||||
public:
|
public:
|
||||||
Restaurant() :
|
Restaurant() :
|
||||||
m_id(0),
|
m_id(0),
|
||||||
m_name(""),
|
m_name(""),
|
||||||
m_status(true)
|
m_isOpen(true)
|
||||||
{}
|
{}
|
||||||
Restaurant(int id, const std::string& name) :
|
Restaurant(int id, const std::string& name) :
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_status(true)
|
m_isOpen(true)
|
||||||
{}
|
{}
|
||||||
~Restaurant();
|
|
||||||
int getId() const;
|
int getId() const;
|
||||||
menuItems& getMenuItems();
|
menuItems& getMenuItems();
|
||||||
orders& getOrders();
|
orders& getOrders();
|
||||||
bool getStatus() const;
|
bool getStatus() const;
|
||||||
void setStatus(bool);
|
void setStatus(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user