Skip to content

Instantly share code, notes, and snippets.

@takaiwa
Last active January 4, 2016 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaiwa/8594108 to your computer and use it in GitHub Desktop.
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
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