blob: 0fc297aa601c7a9e0468a5d29f0f53fb26e46e5d (
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
|
#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;
}
|