Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
idatt1002_2023_9
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
Andreas Kluge Svendsrud
idatt1002_2023_9
Commits
095514b0
Commit
095514b0
authored
2 years ago
by
HSoreide
Browse files
Options
Downloads
Patches
Plain Diff
Write first draft of the RecipeRegister class
parent
0d8d7742
No related branches found
No related tags found
1 merge request
!7
Create food and recipe classes with tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java
+22
-0
22 additions, 0 deletions
...a/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java
with
22 additions
and
0 deletions
src/main/java/no/ntnu/idatt1002/demo/data/recipes/RecipeRegister.java
0 → 100644
+
22
−
0
View file @
095514b0
package
no.ntnu.idatt1002.demo.data.recipes
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
RecipeRegister
{
private
List
<
Recipe
>
recipes
=
new
ArrayList
<>();
//TODO: Copy-constructor
public
void
addRecipe
(
Recipe
recipe
)
{
if
(
recipes
.
contains
(
recipe
))
{
throw
new
IllegalArgumentException
(
"The recipe already exists in the register."
);
// Or just replace?
}
else
if
(
recipe
==
null
)
{
throw
new
IllegalArgumentException
(
"The recipe cannot be null."
);
}
this
.
recipes
.
add
(
recipe
);
}
}
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