blob: 4dc9c22e9d58559518a52779e158814d97aa653b (
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
|
#include "HranaLemur.h"
#include <cstring>
#include <iostream>
int HranaLemur::indexOfRestaurant(const char* name) {
for (int i = 0; i < restaurantsCount; i++) {
if (strcmp(restaurants[i].get_name(), name) == 0)
return i;
}
return -1;
}
void HranaLemur::handleOrder(Order order) {
int rest = indexOfRestaurant(order.get_restaurantName());
if (rest < 0) {
std::cout << "Restaurant " << order.get_restaurantName() << " doesn't exist!" << std::endl;
return;
}
try {
int time = restaurants[rest].giveOrder(order);
std::cout << "Order will take: " << time << std::endl;
}
catch (int errorCode) {
if (errorCode == 1)
std::cout << "The restaurant doesn't offer some product!" << std::endl;
else
throw errorCode;
}
}
|