-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFood.php
46 lines (37 loc) · 1002 Bytes
/
Food.php
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
<?php
namespace p2;
class Food
{
# Properties
private $meal;
private $drink;
# Methods
public function __construct($mealJson1, $drinkJson1)
{
# Load Food data
$mealJson = file_get_contents($mealJson1);
$drinkJson = file_get_contents($drinkJson1);
$this->meal = json_decode($mealJson, true);
$this->drink = json_decode($drinkJson, true);
}
public function getMeal()
{
return $this->meal;
}
public function getDrink()
{
return $this->drink;
}
public function getMealCalorie($mealChosenInForm)
{
return $this->meal[$mealChosenInForm]['calorie'];
}
public function getDrinkCalorie($drinkChosenInForm)
{
return $this->drink[$drinkChosenInForm]['calorie'];
}
public function getTotalCalorie($mealChosenInForm, $drinkChosenInForm)
{
return $this->drink[$drinkChosenInForm]['calorie'] + $this->meal[$mealChosenInForm]['calorie'];
}
}