Last active
January 4, 2016 08:19
-
-
Save takaiwa/8594108 to your computer and use it in GitHub Desktop.
「Let's Play TDD #3: Cleaning Up My Mess」の写経 http://www.takaiwa.net/2014/01/lets-play-tdd-3-cleaning-up-my-mess.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jamesshore.finances; | |
/** | |
* <p> | |
* Let's Play TDD #3: Cleaning Up My Mess | |
* https://www.youtube.com/watch?v=jnMMkXzpOS4 | |
* </p> | |
* Current Source code: | |
* https://www.youtube.com/watch?v=jnMMkXzpOS4&t=870 | |
* | |
* @author takaiwa.net | |
*/ | |
public class SavingAccountYear { | |
private int startingBalance = 0; | |
private int interestRate = 0; | |
public SavingAccountYear(){} | |
public SavingAccountYear(int startingBalance, int interestRate) { | |
this.startingBalance = startingBalance; | |
this.interestRate = interestRate; | |
} | |
public int startingBalance() { | |
return startingBalance; | |
} | |
public void deposit(int amount) { | |
startingBalance += amount; | |
} | |
public int balance() { | |
return startingBalance; | |
} | |
public void withdraw(int amount) { | |
startingBalance -= amount; | |
} | |
public SavingAccountYear nextYear() { | |
return new SavingAccountYear(this.endingBalance(), interestRate); | |
} | |
public int endingBalance() { | |
return balance() + (balance() * interestRate / 100); | |
} | |
public int interestRate() { | |
return interestRate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment