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
491fd364
Commit
491fd364
authored
2 years ago
by
Andreas
Browse files
Options
Downloads
Patches
Plain Diff
ItemRegister class is superclass for IncomeRegister and ExpenseRegister
parent
14f7314f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!9
Added FileHandling class for ItemRegister objects, and reworked ItemRegister with new subclasses
,
!8
Remade ItemRegister class and made FileHandling for ItemRegister-objects with tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegister.java
+42
-0
42 additions, 0 deletions
...a/no/ntnu/idatt1002/demo/data/Economics/ItemRegister.java
with
42 additions
and
0 deletions
src/main/java/no/ntnu/idatt1002/demo/data/Economics/ItemRegister.java
0 → 100644
+
42
−
0
View file @
491fd364
package
no.ntnu.idatt1002.demo.data.Economics
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Register class for storing Item-objects.
*/
public
abstract
class
ItemRegister
{
private
final
List
<
Item
>
items
;
/**
* An "empty" class constructor.
*/
public
ItemRegister
(){
this
.
items
=
new
ArrayList
<>();
}
/**
* Class constructor.
* @param items an ArrayList with Item´s you want to overview.
*/
public
ItemRegister
(
ArrayList
<
Item
>
items
){
this
.
items
=
items
;
}
/**
* Check if the register has Item´s.
* @return true or false depending on if items is empty.
*/
public
boolean
hasItems
(){
return
items
.
isEmpty
();
}
/**
* Get the sum of all Item´s in items
* @return sum of all Item´s
*/
public
double
getTotalSum
(){
return
items
.
stream
().
map
(
Item:
:
getAmount
).
mapToDouble
(
Double:
:
doubleValue
).
sum
();
}
}
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