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
7800a8b5
Commit
7800a8b5
authored
2 years ago
by
HSoreide
Browse files
Options
Downloads
Patches
Plain Diff
Add recurring as a property of the Item class
parent
0702c60c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Hs item class
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/ntnu/idatt1002/demo/data/Item.java
+12
-4
12 additions, 4 deletions
src/main/java/no/ntnu/idatt1002/demo/data/Item.java
with
12 additions
and
4 deletions
src/main/java/no/ntnu/idatt1002/demo/data/Item.java
+
12
−
4
View file @
7800a8b5
...
...
@@ -11,6 +11,7 @@ public class Item {
private
Category
category
;
private
String
description
=
""
;
private
float
price
;
private
final
boolean
recurring
;
/**
* The constructor of a new Item object takes in a Category and a price. The category is a value of the
...
...
@@ -19,12 +20,13 @@ public class Item {
* @param category The category the Item belongs to.
* @param price The price of an Item as a float.
*/
public
Item
(
Category
category
,
float
price
){
public
Item
(
Category
category
,
float
price
,
boolean
recurring
){
if
(
category
==
null
||
price
<=
1.0f
)
{
throw
new
IllegalArgumentException
(
"The item must have a category and a price."
);
}
else
{
this
.
category
=
category
;
this
.
price
=
price
;
this
.
recurring
=
recurring
;
}
}
...
...
@@ -36,8 +38,8 @@ public class Item {
* @param description A description of the item as a String.
* @param price The price of the item as a float.
*/
public
Item
(
Category
category
,
String
description
,
float
price
){
this
(
category
,
price
);
public
Item
(
Category
category
,
String
description
,
float
price
,
boolean
recurring
){
this
(
category
,
price
,
recurring
);
this
.
description
=
description
;
}
...
...
@@ -92,7 +94,13 @@ public class Item {
this
.
price
=
price
;
}
/**
* The method returns true if the transaction is recurring, false otherwise.
* @return True if the transaction is a recurring one, false otherwise.
*/
public
boolean
isRecurring
()
{
return
recurring
;
}
/* @Override
public boolean equals(Object obj) {
...
...
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