Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 09-Practice-19.04.2022 / Restaurant.cpp
diff options
context:
space:
mode:
Commit26cf424c42f9cdc172191faa5b2d1c1fcf350143 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-04-19 21:04:23 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-04-19 21:04:23 +0300
Filesa14e5fa80d1461cf8c0940945f99f47f7979ba22 /Year 1/Object-oriented Programming/09-Practice-19.04.2022/Restaurant.cpp
uni-projects-26cf424c42f9cdc172191faa5b2d1c1fcf350143.tar
uni-projects-26cf424c42f9cdc172191faa5b2d1c1fcf350143.tar.gz
uni-projects-26cf424c42f9cdc172191faa5b2d1c1fcf350143.zip
Parent6d4fa30cfd908e20a2ca2c70864a07007347ce98 (diff)
Added work from todays practice
1 files changed, 33 insertions, 0 deletions
-rw-r--r--Year 1/Object-oriented Programming/09-Practice-19.04.2022/Restaurant.cpp33
diff --git a/Year 1/Object-oriented Programming/09-Practice-19.04.2022/Restaurant.cpp b/Year 1/Object-oriented Programming/09-Practice-19.04.2022/Restaurant.cpp
new file mode 100644
index 0000000..0fc297a
--- /dev/null
+++ b/Year 1/Object-oriented Programming/09-Practice-19.04.2022/Restaurant.cpp
@@ -0,0 +1,33 @@
+#include "Restaurant.h"
+#include <cstring>
+
+int Restaurant::indexOf(const Product& prod) {
+ for (int i = 0; i < productsCount; i++) {
+ if (strcmp(products[i].get_name(), prod.get_name()) == 0)
+ return i;
+ }
+ return -1;
+}
+
+Restaurant::Restaurant() : Restaurant("")
+{}
+
+Restaurant::Restaurant(const char* name) {
+ strcpy(this->name, name);
+ products = new Product[8];
+ productsCount = 0;
+}
+
+void Restaurant::addProduct(Product prod) {
+ products[productsCount++] = prod;
+}
+
+unsigned int Restaurant::giveOrder(Order order) {
+ unsigned int time = 0;
+ for (int i = 0; i < order.get_productCount(); i++) {
+ if (indexOf(order.get_products()[i]) < 0)
+ throw 1;
+ time += strlen(order.get_products()[i].get_name()) * 2.7182818284590452353602874 * 3.14159265358979323846;
+ }
+ return time;
+}