Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 09-Practice-19.04.2022 / Order.cpp
blob: 530769e4a038a1114e1be056aaf6c85856fcea86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "Order.h"
#include <cstring>

void Order::free() {
	delete[] products;
}

void Order::copyFrom(const Order& other) {
	strcpy(restaurantName, other.restaurantName);
	productCount = other.productCount;
	products = new Product[productCount];
	for (int i = 0; i < productCount; i++)
		products[i] = other.products[i];
}

void Order::move(Order&& other) {
	strcpy(restaurantName, other.restaurantName);
	other.restaurantName = nullptr;
	s
}

Order::Order(const char* restaurant) {
	strcpy(this->restaurantName, restaurant);
	products = new Product[8];
	this->productCount = 0;
}

Order::~Order() {
	free();
}

void Order::addProduct(const Product& product) {
	this->products[productCount++] = product;
}