Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tasty Pages
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SE2 Projekt
Tasty Pages
Commits
8238efc3
Commit
8238efc3
authored
1 year ago
by
Blersch Lara
Browse files
Options
Downloads
Patches
Plain Diff
started to implement ShoppingList
parent
9878f2cf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/mi/hdm/mealPlan/MealPlan.java
+1
-0
1 addition, 0 deletions
src/main/java/mi/hdm/mealPlan/MealPlan.java
src/main/java/mi/hdm/shoppingList/ShoppingList.java
+29
-2
29 additions, 2 deletions
src/main/java/mi/hdm/shoppingList/ShoppingList.java
with
30 additions
and
2 deletions
src/main/java/mi/hdm/mealPlan/MealPlan.java
+
1
−
0
View file @
8238efc3
...
...
@@ -7,6 +7,7 @@ import mi.hdm.recipes.Recipe;
* Allow the user to create a meal plan for the week. The user can check out his nutrition scores for the week.
*/
public
class
MealPlan
{
//TODO: implement class<
private
static
final
MealPlan
mealPlan
=
new
MealPlan
();
public
static
MealPlan
getInstance
()
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/mi/hdm/shoppingList/ShoppingList.java
+
29
−
2
View file @
8238efc3
package
mi.hdm.shoppingList
;
import
mi.hdm.exceptions.InvalidIngredientException
;
import
mi.hdm.recipes.Ingredient
;
import
mi.hdm.recipes.IngredientManager
;
import
mi.hdm.recipes.NutritionCalculator
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
/**
* Shopping list that the user can add ingredients to. The elements on the list can be marked as done or undone.
*/
public
class
ShoppingList
{
//TODO: implement class
private
static
final
Logger
log
=
LogManager
.
getLogger
(
ShoppingList
.
class
);
private
final
Map
<
Ingredient
,
Boolean
>
list
;
private
static
final
ShoppingList
shoppingList
=
new
ShoppingList
();
...
...
@@ -22,13 +30,32 @@ public class ShoppingList {
return
shoppingList
;
}
public
void
clear
()
{}
public
void
clear
()
{
list
.
clear
();
log
.
info
(
"ShoppingList cleared successfully."
);
}
public
void
markDone
(
int
id
)
{}
public
void
markDone
(
Ingredient
in
)
{
list
.
put
(
in
,
true
);
log
.
info
(
"Ingredient {} marked as done"
,
in
);
}
public
void
markDone
(
String
name
){
Ingredient
in
=
getIngredientByName
(
name
).
orElseThrow
(()
->
new
InvalidIngredientException
(
"No ingredient with name "
+
name
));;
markDone
(
in
);
}
public
void
markUndone
(
int
id
)
{}
public
Map
<
Ingredient
,
Boolean
>
getList
()
{
return
list
;
}
private
Optional
<
Ingredient
>
getIngredientByName
(
String
name
)
{
for
(
final
Ingredient
i
:
list
.
keySet
())
{
if
(
name
.
equals
(
i
.
getName
()))
{
return
Optional
.
of
(
i
);
}
}
return
Optional
.
empty
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment