forked from joshua840/snu_programming_methodology_project3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmartController.cpp
More file actions
62 lines (58 loc) · 1.89 KB
/
SmartController.cpp
File metadata and controls
62 lines (58 loc) · 1.89 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "SmartController.h"
#include "Controller.h"
#include "Food.h"
/**
* Get maximum height among the foods in this shelf
*
* @return maximum height of the foods.
*/
int SmartController::maxHeight(Shelf &shelf)
{
if (shelf.vec.empty())
return 0;
auto comp = [](const FoodPtr a, const FoodPtr b)
{
return (a->getSize().second < b->getSize().second);
};
auto it_shelf = max_element(shelf.vec.begin(), shelf.vec.end(), comp);
return (*it_shelf)->getSize().second;
}
/**
* Store a given food object into the refrigerator
*
* This function should follows the 'Shelf First Fit (Shelf-FF) algorithm, which is given in the PPT slide.
* Your implemented algorithm should find the proper position of the new food.
* Also, the given food object may in the stack memory. You should save it in the heap memory and reference
* it from both food_list and shelves.
*
* @param name The name of the food to be stored
* @param size width and height of the food
* @param exp the expire date of the food
* @return true if inserting the food for both food_list and shelves has been succeed
*/
bool SmartController::stackFood(const string name, intPair foodSize, int exp)
{
/**
* ===============================================
* ======== TODO: Implement this function ========
* ===============================================
*/
return false;
}
/**
* Pop food with shortest expire date from both foodList and shelves.
* This function does not return the object.
* The pop process should follows the algorithm in PPT slide.
*
* @param food_name a name of food to be popped
* @return
*/
bool SmartController::popFood(const string food_name) // void
{
/**
* ===============================================
* ======== TODO: Implement this function ========
* ===============================================
*/
return false;
}