-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdinner.cpp
More file actions
25 lines (22 loc) · 780 Bytes
/
Copy pathdinner.cpp
File metadata and controls
25 lines (22 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "dinner.h"
#include "Dish.h"
#include "complexdinner.h"
bool cmp(Dinner * a, Dinner * b){
return a->caloricity() < b->caloricity();
}
void fromJSFile(Tree_RB<Dinner *> * tree, QJsonArray & JSArray){
foreach (auto element, JSArray) {
if ((DinnerType)element.toObject()["Type"].toInt() == COMPLEX_DINNER){
Dinner * dinner = new ComplexDinner();
dinner->fromJSFile(element.toObject());
tree->insert(dinner);;
} else /*if((DinnerType)element.toObject()["Type"].toInt() == DISH)*/ {
Dinner * dinner = new Dish();
dinner->fromJSFile(element.toObject());
tree->insert(dinner);
}
}
}
void inJSFile(Dinner * din, QJsonArray & JSArray){
din->inJSFile(JSArray);
}