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
3831b952
Commit
3831b952
authored
2 years ago
by
Andreas
Browse files
Options
Downloads
Patches
Plain Diff
Added javadoc, get- and add methods
parent
a23f0103
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
ItemOverview class (with test class)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/no/ntnu/idatt1002/demo/Income.java
+53
-0
53 additions, 0 deletions
src/main/java/no/ntnu/idatt1002/demo/Income.java
src/main/java/no/ntnu/idatt1002/demo/IncomeOverview.java
+0
-11
0 additions, 11 deletions
src/main/java/no/ntnu/idatt1002/demo/IncomeOverview.java
with
53 additions
and
11 deletions
src/main/java/no/ntnu/idatt1002/demo/Income.java
0 → 100644
+
53
−
0
View file @
3831b952
package
no.ntnu.idatt1002.demo
;
/**
* Income is for registering information about your income,
* and editing it.
* @author Andreas
*/
public
class
Income
{
private
double
totalIncome
;
private
final
double
fixedIncome
;
/**
* Class constructor
* @param fixedIncome An income which you will always receive, for example a loan.
*/
protected
Income
(
double
fixedIncome
){
if
(
fixedIncome
<
0
){
throw
new
IllegalArgumentException
(
"You can not have a negativ income"
);
}
this
.
totalIncome
=
fixedIncome
;
this
.
fixedIncome
=
fixedIncome
;
}
/**
* Return the fixed income of the income.
* @return The income´s fixed income.
*/
public
double
getFixedIncome
()
{
double
copyFixedIncome
=
fixedIncome
;
return
copyFixedIncome
;
}
/**
* Return the total income.
* @return The total income.
*/
public
double
getIncome
()
{
double
copyIncome
=
totalIncome
;
return
copyIncome
;
}
/**
* Adding an amount to your total income.
* If the amount is negativ an IllegalArgumentException is thrown
* @param amount The amount you want to add to your total income.
*/
public
void
addIncome
(
double
amount
){
if
(
amount
<
0
){
throw
new
IllegalArgumentException
(
"You can not add a negative amount to income"
);
}
totalIncome
+=
amount
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/no/ntnu/idatt1002/demo/IncomeOverview.java
deleted
100644 → 0
+
0
−
11
View file @
a23f0103
package
no.ntnu.idatt1002.demo
;
public
class
IncomeOverview
{
private
double
income
;
private
final
double
fixedIncome
;
public
IncomeOverview
(
double
fixedIncome
){
this
.
income
=
fixedIncome
;
this
.
fixedIncome
=
fixedIncome
;
}
}
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