Skip to content
Snippets Groups Projects
Commit 3831b952 authored by Andreas's avatar Andreas
Browse files

Added javadoc, get- and add methods

parent a23f0103
No related branches found
No related tags found
1 merge request!4ItemOverview class (with test class)
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;
}
}
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment