#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Product {
private:
string name;
double price;
string category;
public:
Product() {}
Product(string name, double price, string category) {
this->name = name;
this->price = price;
this->category = category;
}
void setName(string name) {
this->name = name;
}
string getName() {
return name;
}
void setCategory(string category) {
this->category = category;
}
string getCategort() {
return category;
}
void setPrice(double price) {
this->price = price;
}
double getPrice() {
return price;
}
void print() {
cout << name << " - " << category << " - " << price << "GEL";
}
};
class OrderItem {
private:
Product product;
int quantity;
public:
OrderItem(Product product, int quantity) {
this->product = product;
this->quantity = quantity;
}
void setQuantity(double quantity) {
this->quantity = quantity;
}
double getQuantity() {
return quantity;
}
void setProducts(Product product) {
this->product = product;
}
Product getProduct() {
return product;
}
};
class Order {
private:
double total;
vector<OrderItem> items;
void setTotal() {
this->total = 0;
for (auto x : items) {
this->total += x.getProduct().getPrice() * x.getQuantity();
}
}
public:
Order() {}
Order(vector<OrderItem> items) {
this->items = items;
this->setTotal();
}
double getTotal() {
return total;
}
void setOrderItems(vector<OrderItem> items) {
this->items = items;
this->setTotal();
}
vector<OrderItem> getItems() {
return items;
}
void print() {
cout << "<<<<< ORDER INTO >>>>>" << endl;
for (auto x : this->items) {
x.getProduct().print();
cout << " x " << x.getQuantity() << endl;
}
cout << "<<<< TOTAL: " << this->total << "GEL" << endl;
}
};
int main() {
Product prod1("apple", 2000, "laptop");
Product prod2("loud speaker", 100, "speakers");
vector<OrderItem> items;
items.push_back(OrderItem(prod1, 1));
items.push_back(OrderItem(prod2, 2));
Order order(items);
order.print();
return 0;
}