Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bakeri
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eskil Helgesen Schjølberg
bakeri
Commits
40fa0432
Commit
40fa0432
authored
3 years ago
by
Eskil Helgesen Schjølberg
Browse files
Options
Downloads
Patches
Plain Diff
Innlevering
parent
3d9d95ab
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
system/Controller.java
+58
-0
58 additions, 0 deletions
system/Controller.java
system/Ingrediens.java
+33
-0
33 additions, 0 deletions
system/Ingrediens.java
system/Recipe.java
+48
-0
48 additions, 0 deletions
system/Recipe.java
with
140 additions
and
1 deletion
README.md
+
1
−
1
View file @
40fa0432
# bakeri
System for bakeri
\ No newline at end of file
System for bakeri. Ble et stykke unna ferdig, så er ikke klar for kjøring.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
system/Controller.java
0 → 100644
+
58
−
0
View file @
40fa0432
package
system
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
public
class
Controller
{
private
List
<
Ingrediens
>
inventoryList
=
new
ArrayList
<>();
private
List
<
Recipe
>
recipeList
=
new
ArrayList
<>();
public
void
registerNewIng
(
String
name
,
int
inventoryGrams
)
{
//Feilhaandtering
Ingrediens
ingrediens
=
new
Ingrediens
(
name
,
inventoryGrams
);
inventoryList
.
add
(
ingrediens
);
}
public
void
registerNewRec
(
String
name
,
String
productType
,
List
<
Ingrediens
>
ingrediensList
)
{
//Feilhaandtering
Recipe
recipe
=
new
Recipe
(
name
,
productType
,
ingrediensList
);
recipeList
.
add
(
recipe
);
}
public
void
updateInventory
(
int
ingID
,
int
gramsAdded
)
{
inventoryList
.
get
(
ingID
-
1
).
addGrams
(
gramsAdded
);
}
public
List
<
Recipe
>
getAllRecByType
(
String
type
)
{
List
<
Recipe
>
recipeListByType
=
new
ArrayList
<>();
for
(
Recipe
recipe
:
recipeList
)
{
if
(
recipe
.
getProductType
().
equalsIgnoreCase
(
type
))
{
recipeListByType
.
add
(
recipe
);
}
}
recipeListByType
.
sort
(
new
RecipeSorter
());
return
recipeListByType
;
}
public
class
RecipeSorter
implements
Comparator
<
Recipe
>
{
@Override
public
int
compare
(
Recipe
o1
,
Recipe
o2
)
{
String
a
=
o2
.
getName
();
String
b
=
o1
.
getName
();
return
a
.
compareTo
(
b
);
}
}
/*
public boolean produceNumberOfProducts(int rec_id) {
//Rakk ikke
}
public boolean removeAmountOfIng(int amount, int rec_id){
//Rakk ikke
}
*/
}
This diff is collapsed.
Click to expand it.
system/Ingrediens.java
0 → 100644
+
33
−
0
View file @
40fa0432
package
system
;
public
class
Ingrediens
{
private
static
int
ing_id_generator
=
0
;
int
ingID
;
String
name
;
int
inventoryGrams
;
public
Ingrediens
(
String
name
,
int
inventoryGrams
)
{
ing_id_generator
++;
this
.
ingID
=
ing_id_generator
;
this
.
name
=
name
;
this
.
inventoryGrams
=
inventoryGrams
;
}
public
int
getIngID
()
{
return
ingID
;
}
public
String
getName
()
{
return
name
;
}
public
int
getInventoryGrams
()
{
return
inventoryGrams
;
}
public
void
addGrams
(
int
gramsAdded
)
{
inventoryGrams
=
inventoryGrams
+
gramsAdded
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
system/Recipe.java
0 → 100644
+
48
−
0
View file @
40fa0432
package
system
;
import
java.sql.Time
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Recipe
{
private
static
int
rec_id_generator
=
0
;
int
recipeID
;
String
name
;
SimpleDateFormat
date
;
String
productType
;
private
List
<
Ingrediens
>
ingrediensList
;
public
Recipe
(
String
name
,
String
productType
,
List
<
Ingrediens
>
ingrediensList
){
rec_id_generator
++;
recipeID
=
rec_id_generator
;
//date
this
.
name
=
name
;
this
.
productType
=
productType
;
this
.
ingrediensList
=
ingrediensList
;
}
public
SimpleDateFormat
getDate
()
{
return
date
;
}
public
List
<
Ingrediens
>
getIngrediensList
()
{
return
ingrediensList
;
}
public
String
getName
()
{
return
name
;
}
public
String
getProductType
()
{
return
productType
;
}
public
int
getRecipeID
()
{
return
recipeID
;
}
}
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