From 26cf424c42f9cdc172191faa5b2d1c1fcf350143 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 19 Apr 2022 21:04:23 +0300 Subject: Added work from todays practice --- .../09-Practice-19.04.2022/Order.cpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Year 1/Object-oriented Programming/09-Practice-19.04.2022/Order.cpp (limited to 'Year 1/Object-oriented Programming/09-Practice-19.04.2022/Order.cpp') diff --git a/Year 1/Object-oriented Programming/09-Practice-19.04.2022/Order.cpp b/Year 1/Object-oriented Programming/09-Practice-19.04.2022/Order.cpp new file mode 100644 index 0000000..530769e --- /dev/null +++ b/Year 1/Object-oriented Programming/09-Practice-19.04.2022/Order.cpp @@ -0,0 +1,34 @@ +#include "Order.h" +#include + +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; +} -- cgit v1.3.1-23-gd82d