Commit faf2692
Changed files (12)
assignments
assignment1
src
main
java
test
assignments/assignment1/src/main/java/ca/mokhan/assignment1/AddressBook.java
@@ -2,8 +2,7 @@ package ca.mokhan.assignment1;
import java.util.Objects;
-public class AddressBook implements Comparable<AddressBook>
-{
+public class AddressBook implements Comparable<AddressBook> {
private String businessPhone;
private String cellPhone;
private String facebookId;
@@ -15,9 +14,18 @@ public class AddressBook implements Comparable<AddressBook>
private String personalWebSite;
private String skypeId;
- public AddressBook() { this(""); }
- public AddressBook(String firstName) { this(firstName, "", ""); }
- public AddressBook(String firstName, String middleName, String lastName) { this(firstName, middleName, lastName, "", "", "", "", "", "", ""); }
+ public AddressBook() {
+ this("");
+ }
+
+ public AddressBook(String firstName) {
+ this(firstName, "", "");
+ }
+
+ public AddressBook(String firstName, String middleName, String lastName) {
+ this(firstName, middleName, lastName, "", "", "", "", "", "", "");
+ }
+
public AddressBook(
String firstName,
String middleName,
@@ -27,7 +35,8 @@ public class AddressBook implements Comparable<AddressBook>
String facebookId,
String homeAddress,
String homePhone,
- String personalWebSite, String skypeId) {
+ String personalWebSite,
+ String skypeId) {
this.businessPhone = businessPhone;
this.cellPhone = cellPhone;
this.facebookId = facebookId;
@@ -40,38 +49,94 @@ public class AddressBook implements Comparable<AddressBook>
this.skypeId = skypeId;
}
- public String getBusinessPhone() { return this.businessPhone; }
- public String getCellPhone() { return this.cellPhone; }
- public String getFacebookId() { return this.facebookId; }
- public String getFirstName() { return this.firstName; }
- public String getHomeAddress() { return this.homeAddress; }
- public String getHomePhone() { return this.homePhone; }
- public String getLastName() { return this.lastName; }
- public String getMiddleName() { return this.middleName; }
- public String getPersonalWebSite() { return this.personalWebSite; }
- public String getSkypeId() { return this.skypeId; }
-
- public void setBusinessPhone(String value) { this.businessPhone = value; }
- public void setCellPhone(String value) { this.cellPhone = value; }
- public void setFacebookId(String value) { this.facebookId = value; }
- public void setFirstName(String name) { this.firstName = name; }
- public void setHomeAddress(String address) { this.homeAddress = address; }
- public void setHomePhone(String value) { this.homePhone = value; }
- public void setLastName(String name) { this.lastName = name; }
- public void setMiddleName(String name) { this.middleName = name; }
- public void setPersonalWebSite(String value) { this.personalWebSite = value; }
- public void setSkypeId(String value) { this.skypeId = value; }
-
- public static String compareNames(String name1, String name2)
- {
+ public String getBusinessPhone() {
+ return this.businessPhone;
+ }
+
+ public String getCellPhone() {
+ return this.cellPhone;
+ }
+
+ public String getFacebookId() {
+ return this.facebookId;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public String getHomeAddress() {
+ return this.homeAddress;
+ }
+
+ public String getHomePhone() {
+ return this.homePhone;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public String getMiddleName() {
+ return this.middleName;
+ }
+
+ public String getPersonalWebSite() {
+ return this.personalWebSite;
+ }
+
+ public String getSkypeId() {
+ return this.skypeId;
+ }
+
+ public void setBusinessPhone(String value) {
+ this.businessPhone = value;
+ }
+
+ public void setCellPhone(String value) {
+ this.cellPhone = value;
+ }
+
+ public void setFacebookId(String value) {
+ this.facebookId = value;
+ }
+
+ public void setFirstName(String name) {
+ this.firstName = name;
+ }
+
+ public void setHomeAddress(String address) {
+ this.homeAddress = address;
+ }
+
+ public void setHomePhone(String value) {
+ this.homePhone = value;
+ }
+
+ public void setLastName(String name) {
+ this.lastName = name;
+ }
+
+ public void setMiddleName(String name) {
+ this.middleName = name;
+ }
+
+ public void setPersonalWebSite(String value) {
+ this.personalWebSite = value;
+ }
+
+ public void setSkypeId(String value) {
+ this.skypeId = value;
+ }
+
+ public static String compareNames(String name1, String name2) {
return Integer.toString(name1.compareTo(name2));
}
- public int compareTo(AddressBook other)
- {
- return this.firstName.compareTo(other.firstName) +
- this.middleName.compareTo(other.middleName) +
- this.lastName.compareTo(other.lastName);
+ public int compareTo(AddressBook other) {
+ return this.firstName.compareTo(other.firstName)
+ + this.middleName.compareTo(other.middleName)
+ + this.lastName.compareTo(other.lastName);
}
@Override
@@ -79,21 +144,31 @@ public class AddressBook implements Comparable<AddressBook>
if (this == o) return true;
if (!(o instanceof AddressBook)) return false;
AddressBook that = (AddressBook) o;
- return Objects.equals(businessPhone, that.businessPhone) &&
- Objects.equals(cellPhone, that.cellPhone) &&
- Objects.equals(facebookId, that.facebookId) &&
- Objects.equals(firstName, that.firstName) &&
- Objects.equals(homeAddress, that.homeAddress) &&
- Objects.equals(homePhone, that.homePhone) &&
- Objects.equals(lastName, that.lastName) &&
- Objects.equals(middleName, that.middleName) &&
- Objects.equals(personalWebSite, that.personalWebSite) &&
- Objects.equals(skypeId, that.skypeId);
+ return Objects.equals(businessPhone, that.businessPhone)
+ && Objects.equals(cellPhone, that.cellPhone)
+ && Objects.equals(facebookId, that.facebookId)
+ && Objects.equals(firstName, that.firstName)
+ && Objects.equals(homeAddress, that.homeAddress)
+ && Objects.equals(homePhone, that.homePhone)
+ && Objects.equals(lastName, that.lastName)
+ && Objects.equals(middleName, that.middleName)
+ && Objects.equals(personalWebSite, that.personalWebSite)
+ && Objects.equals(skypeId, that.skypeId);
}
@Override
public int hashCode() {
- return Objects.hash(businessPhone, cellPhone, facebookId, firstName, homeAddress, homePhone, lastName, middleName, personalWebSite, skypeId);
+ return Objects.hash(
+ businessPhone,
+ cellPhone,
+ facebookId,
+ firstName,
+ homeAddress,
+ homePhone,
+ lastName,
+ middleName,
+ personalWebSite,
+ skypeId);
}
@Override
assignments/assignment1/src/main/java/ca/mokhan/assignment1/App.java
@@ -1,9 +1,7 @@
package ca.mokhan.assignment1;
-public class App
-{
- public static void main(String[] args)
- {
+public class App {
+ public static void main(String[] args) {
System.out.println("Hello World!");
}
}
assignments/assignment1/src/main/java/ca/mokhan/assignment1/BanffMarathonRunner.java
@@ -1,11 +1,9 @@
package ca.mokhan.assignment1;
-import java.util.Arrays;
-import java.util.Objects;
import java.util.ArrayList;
+import java.util.Arrays;
-public class BanffMarathonRunner extends AddressBook
-{
+public class BanffMarathonRunner extends AddressBook {
private int time;
private int years;
@@ -15,9 +13,8 @@ public class BanffMarathonRunner extends AddressBook
this.years = years;
}
- public int compareTo(AddressBook other)
- {
- BanffMarathonRunner runner = (BanffMarathonRunner)other;
+ public int compareTo(AddressBook other) {
+ BanffMarathonRunner runner = (BanffMarathonRunner) other;
return Integer.compare(this.time, runner.time);
}
@@ -26,33 +23,28 @@ public class BanffMarathonRunner extends AddressBook
return super.getFirstName() + " " + this.years;
}
- public static BanffMarathonRunner getFastestRunner(BanffMarathonRunner[] runners)
- {
+ public static BanffMarathonRunner getFastestRunner(BanffMarathonRunner[] runners) {
Arrays.sort(runners);
return runners[0];
}
- public static BanffMarathonRunner getSecondFastestRunner(BanffMarathonRunner[] runners)
- {
+ public static BanffMarathonRunner getSecondFastestRunner(BanffMarathonRunner[] runners) {
Arrays.sort(runners);
return runners[1];
}
- public static int getAverageTime(BanffMarathonRunner[] runners)
- {
+ public static int getAverageTime(BanffMarathonRunner[] runners) {
int sum = 0;
for (BanffMarathonRunner runner : runners) sum += runner.time;
return sum / runners.length;
}
- public static String getAboveAverageRunners(BanffMarathonRunner[] runners)
- {
+ public static String getAboveAverageRunners(BanffMarathonRunner[] runners) {
int average = getAverageTime(runners);
ArrayList<String> winners = new ArrayList<String>();
for (BanffMarathonRunner runner : runners)
- if (runner.time >= average)
- winners.add(runner.toString());
+ if (runner.time >= average) winners.add(runner.toString());
return String.join(System.lineSeparator(), winners);
}
assignments/assignment1/src/main/java/ca/mokhan/assignment1/BonusOnSavings.java
@@ -1,29 +1,27 @@
package ca.mokhan.assignment1;
-import java.util.Objects;
-
-public class BonusOnSavings
-{
+public class BonusOnSavings {
double annualRate = 0.0;
double quarterlyRate = 0.0;
- public BonusOnSavings() { this(0.03, 0.05); }
+ public BonusOnSavings() {
+ this(0.03, 0.05);
+ }
public BonusOnSavings(double quarterlyRate, double annualRate) {
this.quarterlyRate = quarterlyRate;
this.annualRate = annualRate;
}
- public double computeBonus(double monthlyCommitment, double q1, double q2, double q3, double q4)
- {
+ public double computeBonus(double monthlyCommitment, double q1, double q2, double q3, double q4) {
double quarterlyTarget = monthlyCommitment * 3;
double annualTarget = monthlyCommitment * 12;
- return this.quarterlyBonus(quarterlyTarget, q1) +
- this.quarterlyBonus(quarterlyTarget, q2) +
- this.quarterlyBonus(quarterlyTarget, q3) +
- this.quarterlyBonus(quarterlyTarget, q4) +
- this.annualBonus(annualTarget, q1 + q2 + q3 + q4);
+ return this.quarterlyBonus(quarterlyTarget, q1)
+ + this.quarterlyBonus(quarterlyTarget, q2)
+ + this.quarterlyBonus(quarterlyTarget, q3)
+ + this.quarterlyBonus(quarterlyTarget, q4)
+ + this.annualBonus(annualTarget, q1 + q2 + q3 + q4);
}
private double quarterlyBonus(double target, double actual) {
assignments/assignment1/src/main/java/ca/mokhan/assignment1/CartesianCoordinateSystem.java
@@ -1,11 +1,7 @@
package ca.mokhan.assignment1;
-import java.util.Objects;
-
-public class CartesianCoordinateSystem
-{
- public double calculateDistance(double x1, double y1, double x2, double y2)
- {
+public class CartesianCoordinateSystem {
+ public double calculateDistance(double x1, double y1, double x2, double y2) {
return Math.round(Math.pow(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2), 0.5) * 100) / 100.0;
}
}
assignments/assignment1/src/main/java/ca/mokhan/assignment1/EmployeeSavings.java
@@ -1,60 +1,57 @@
package ca.mokhan.assignment1;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Currency;
import java.util.Locale;
-import java.util.Objects;
import java.util.Random;
-public class EmployeeSavings extends AddressBook
-{
+public class EmployeeSavings extends AddressBook {
private double accountValue;
private double[] monthlyInterests;
private double[] monthlySavings;
private double monthlyContribution;
public static final double ANNUAL_INTEREST_RATE = 0.05;
- public EmployeeSavings(String firstName, String lastName)
- {
+ public EmployeeSavings(String firstName, String lastName) {
this(firstName, lastName, new Random().nextInt(800 - 100) + 100.0);
}
- public EmployeeSavings(String firstName, String lastName, double monthlyContribution)
- {
+ public EmployeeSavings(String firstName, String lastName, double monthlyContribution) {
super(firstName, "", lastName);
this.monthlyContribution = monthlyContribution;
this.accountValue = predictBalanceAfterMonths(12);
}
// what is d1, d2?
- public EmployeeSavings(String firstName, String lastName, double[] d1, double[] d2)
- {
+ public EmployeeSavings(String firstName, String lastName, double[] d1, double[] d2) {
super(firstName, "", lastName);
}
- public double getAccountValue() { return this.accountValue; }
- public double[] getMonthlyInterests() { return this.monthlyInterests; }
- public double[] getMonthlySavings() { return this.monthlySavings; }
+ public double getAccountValue() {
+ return this.accountValue;
+ }
+
+ public double[] getMonthlyInterests() {
+ return this.monthlyInterests;
+ }
+
+ public double[] getMonthlySavings() {
+ return this.monthlySavings;
+ }
- public double[] calculateInterests()
- {
+ public double[] calculateInterests() {
this.monthlyInterests = new double[12];
- for (int i = 1; i <= 12; i++)
- this.monthlyInterests[i-1] = predictInterestAfterMonths(i);
+ for (int i = 1; i <= 12; i++) this.monthlyInterests[i - 1] = predictInterestAfterMonths(i);
return this.monthlyInterests;
}
- public double[] generateMonthlySavings()
- {
+ public double[] generateMonthlySavings() {
this.monthlySavings = new double[12];
- for (int i = 1; i <= 12; i++)
- this.monthlySavings[i-1] = predictBalanceAfterMonths(i);
+ for (int i = 1; i <= 12; i++) this.monthlySavings[i - 1] = predictBalanceAfterMonths(i);
return this.monthlySavings;
}
- public double predictBalanceAfterMonths(int months)
- {
+ public double predictBalanceAfterMonths(int months) {
double monthlyRate = ANNUAL_INTEREST_RATE / 12.0;
double balance = 0;
@@ -64,30 +61,24 @@ public class EmployeeSavings extends AddressBook
return Math.round(balance * 1000) / 1000.0;
}
- public double predictInterestAfterMonths(int months)
- {
- return Math.round((predictBalanceAfterMonths(months) - (months * this.monthlyContribution)) * 1000) / 1000.0;
+ public double predictInterestAfterMonths(int months) {
+ return Math.round(
+ (predictBalanceAfterMonths(months) - (months * this.monthlyContribution)) * 1000)
+ / 1000.0;
}
- public static String getReport(EmployeeSavings[] accounts)
- {
+ public static String getReport(EmployeeSavings[] accounts) {
ArrayList<String> statement = new ArrayList<String>();
- for (EmployeeSavings account : accounts)
- statement.add(account.toString());
+ for (EmployeeSavings account : accounts) statement.add(account.toString());
return String.join(System.lineSeparator(), statement);
}
@Override
- public String toString()
- {
+ public String toString() {
Currency currency = Currency.getInstance(Locale.getDefault());
return String.format(
- "%s %s%.2f",
- super.getFirstName(),
- currency.getSymbol(),
- this.getAccountValue()
- );
+ "%s %s%.2f", super.getFirstName(), currency.getSymbol(), this.getAccountValue());
}
}
assignments/assignment1/src/test/java/ca/mokhan/assignment1/AddressBookTest.java
@@ -4,90 +4,78 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class AddressBookTest extends TestCase
-{
+public class AddressBookTest extends TestCase {
private AddressBook subject;
- public AddressBookTest(String testName)
- {
+ public AddressBookTest(String testName) {
super(testName);
this.subject = new AddressBook();
}
- public static Test suite()
- {
+ public static Test suite() {
return new TestSuite(AddressBookTest.class);
}
- public void testFirstName()
- {
+ public void testFirstName() {
subject.setFirstName("mo");
assertEquals(subject.getFirstName(), "mo");
}
- public void testMiddleName()
- {
+ public void testMiddleName() {
subject.setMiddleName("tsuyoshi");
assertEquals(subject.getMiddleName(), "tsuyoshi");
}
- public void testLastName()
- {
+ public void testLastName() {
subject.setLastName("garrett");
assertEquals(subject.getLastName(), "garrett");
}
- public void testHomeAddress()
- {
+ public void testHomeAddress() {
subject.setHomeAddress("1 University Dr, Athabasca, AB T9S 3A3");
assertEquals(subject.getHomeAddress(), "1 University Dr, Athabasca, AB T9S 3A3");
}
- public void testBusinessPhone()
- {
+ public void testBusinessPhone() {
subject.setBusinessPhone("1-800-788-9041");
assertEquals(subject.getBusinessPhone(), "1-800-788-9041");
}
- public void testHomePhone()
- {
+ public void testHomePhone() {
subject.setHomePhone("1-800-788-9041");
assertEquals(subject.getHomePhone(), "1-800-788-9041");
}
- public void testCellPhone()
- {
+ public void testCellPhone() {
subject.setCellPhone("1-800-788-9041");
assertEquals(subject.getCellPhone(), "1-800-788-9041");
}
- public void testSkypeId()
- {
+ public void testSkypeId() {
subject.setSkypeId("1-800-788-9041");
assertEquals(subject.getSkypeId(), "1-800-788-9041");
}
- public void testFacebookId()
- {
+ public void testFacebookId() {
subject.setFacebookId("1-800-788-9041");
assertEquals(subject.getFacebookId(), "1-800-788-9041");
}
- public void testPersonalWebsite()
- {
+ public void testPersonalWebsite() {
subject.setPersonalWebSite("https://www.mokhan.ca/");
assertEquals(subject.getPersonalWebSite(), "https://www.mokhan.ca/");
}
- public void testCompareNames()
- {
- assertTrue(Integer.parseInt(AddressBook.compareNames("Tsuyoshi M. Garret", "Takashi Shirogane")) > 0);
- assertTrue(Integer.parseInt(AddressBook.compareNames("Takashi Shirogane", "Tsuyoshi M. Garret")) < 0);
- assertTrue(Integer.parseInt(AddressBook.compareNames("Tsuyoshi Garret", "Tsuyoshi Garret")) == 0);
+ public void testCompareNames() {
+ assertTrue(
+ Integer.parseInt(AddressBook.compareNames("Tsuyoshi M. Garret", "Takashi Shirogane")) > 0);
+ assertTrue(
+ Integer.parseInt(AddressBook.compareNames("Takashi Shirogane", "Tsuyoshi M. Garret")) < 0);
+ assertTrue(
+ Integer.parseInt(AddressBook.compareNames("Tsuyoshi Garret", "Tsuyoshi Garret")) == 0);
}
- public void testCompareTo()
- {
+ public void testCompareTo() {
AddressBook hunk = new AddressBook();
hunk.setFirstName("Tsuyoshi");
hunk.setLastName("Garrett");
assignments/assignment1/src/test/java/ca/mokhan/assignment1/AppTest.java
@@ -4,20 +4,16 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class AppTest extends TestCase
-{
- public AppTest(String testName)
- {
+public class AppTest extends TestCase {
+ public AppTest(String testName) {
super(testName);
}
- public static Test suite()
- {
+ public static Test suite() {
return new TestSuite(AppTest.class);
}
- public void testApp()
- {
+ public void testApp() {
assertTrue(true);
}
}
assignments/assignment1/src/test/java/ca/mokhan/assignment1/BanffMarathonRunnerTest.java
@@ -4,8 +4,7 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class BanffMarathonRunnerTest extends TestCase
-{
+public class BanffMarathonRunnerTest extends TestCase {
private BanffMarathonRunner john = new BanffMarathonRunner("John", "Lenthen", 243, 1);
private BanffMarathonRunner kate = new BanffMarathonRunner("Kate", "Hen", 265, 8);
private BanffMarathonRunner[] runners = {
@@ -26,43 +25,37 @@ public class BanffMarathonRunnerTest extends TestCase
this.kate
};
- public BanffMarathonRunnerTest(String testName)
- {
+ public BanffMarathonRunnerTest(String testName) {
super(testName);
}
- public static Test suite()
- {
+ public static Test suite() {
return new TestSuite(BanffMarathonRunnerTest.class);
}
- public void testGetFastestRunner()
- {
+ public void testGetFastestRunner() {
assertEquals(this.john, BanffMarathonRunner.getFastestRunner(this.runners));
}
- public void testGetSecondFastestRunner()
- {
+ public void testGetSecondFastestRunner() {
assertEquals(this.kate, BanffMarathonRunner.getSecondFastestRunner(this.runners));
}
- public void testGetAverageTime()
- {
+ public void testGetAverageTime() {
assertEquals(321, BanffMarathonRunner.getAverageTime(this.runners));
}
- public void testGetAboveAverageRunners()
- {
- String expected = String.join(
- System.lineSeparator(),
- "Elena 1",
- "Suzie 7",
- "Philip 9",
- "James 1",
- "Jane 1",
- "Emily 4",
- "Neda 3"
- );
+ public void testGetAboveAverageRunners() {
+ String expected =
+ String.join(
+ System.lineSeparator(),
+ "Elena 1",
+ "Suzie 7",
+ "Philip 9",
+ "James 1",
+ "Jane 1",
+ "Emily 4",
+ "Neda 3");
assertEquals(expected, BanffMarathonRunner.getAboveAverageRunners(this.runners));
}
}
assignments/assignment1/src/test/java/ca/mokhan/assignment1/BonusOnSavingsTest.java
@@ -4,28 +4,23 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class BonusOnSavingsTest extends TestCase
-{
+public class BonusOnSavingsTest extends TestCase {
private BonusOnSavings subject;
- public BonusOnSavingsTest(String testName)
- {
+ public BonusOnSavingsTest(String testName) {
super(testName);
this.subject = new BonusOnSavings();
}
- public static Test suite()
- {
+ public static Test suite() {
return new TestSuite(BonusOnSavingsTest.class);
}
- public void testComputeBonusEmployeeOne()
- {
+ public void testComputeBonusEmployeeOne() {
assertEquals(1650.00, subject.computeBonus(2000, 5000, 7000, 4000, 8000));
}
- public void testComputeBonusEmployeeTwo()
- {
+ public void testComputeBonusEmployeeTwo() {
assertEquals(4680.00, subject.computeBonus(3000, 6000, 9000, 10000, 17000));
}
}
assignments/assignment1/src/test/java/ca/mokhan/assignment1/CartesianCoordinateSystemTest.java
@@ -4,23 +4,19 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class CartesianCoordinateSystemTest extends TestCase
-{
+public class CartesianCoordinateSystemTest extends TestCase {
private CartesianCoordinateSystem subject;
- public CartesianCoordinateSystemTest(String testName)
- {
+ public CartesianCoordinateSystemTest(String testName) {
super(testName);
this.subject = new CartesianCoordinateSystem();
}
- public static Test suite()
- {
+ public static Test suite() {
return new TestSuite(CartesianCoordinateSystemTest.class);
}
- public void testDistanceBetweenPoints()
- {
+ public void testDistanceBetweenPoints() {
assertEquals(7.28, subject.calculateDistance(-2, -3, -4, 4));
}
}
assignments/assignment1/src/test/java/ca/mokhan/assignment1/EmployeeSavingsTest.java
@@ -4,24 +4,20 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class EmployeeSavingsTest extends TestCase
-{
+public class EmployeeSavingsTest extends TestCase {
private EmployeeSavings subject;
- public EmployeeSavingsTest(String testName)
- {
+ public EmployeeSavingsTest(String testName) {
super(testName);
double monthlyContribution = 100.00;
this.subject = new EmployeeSavings("Tsuyoshi", "Garrett", monthlyContribution);
}
- public static Test suite()
- {
+ public static Test suite() {
return new TestSuite(EmployeeSavingsTest.class);
}
- public void testPredictSavingsAfter1Month()
- {
+ public void testPredictSavingsAfter1Month() {
// Bankers rounding rules would round this amount down to $100.41
// the $0.007 would go to the bank.
assertEquals(100.417, subject.predictBalanceAfterMonths(1));
@@ -29,8 +25,7 @@ public class EmployeeSavingsTest extends TestCase
assertEquals(302.507, subject.predictBalanceAfterMonths(3));
}
- public void testPredictInterestAfter1Month()
- {
+ public void testPredictInterestAfter1Month() {
// Bankers rounding rules would round this amount down to $100.41
// the $0.007 would go to the bank.
assertEquals(0.417, subject.predictInterestAfterMonths(1));
@@ -38,13 +33,11 @@ public class EmployeeSavingsTest extends TestCase
assertEquals(2.507, subject.predictInterestAfterMonths(3));
}
- public void testGetAccountValue()
- {
+ public void testGetAccountValue() {
assertEquals(subject.predictBalanceAfterMonths(12), subject.getAccountValue());
}
- public void testCalculateInterests()
- {
+ public void testCalculateInterests() {
assertEquals(0.417, subject.calculateInterests()[0]);
assertEquals(1.252, subject.calculateInterests()[1]);
assertEquals(2.507, subject.calculateInterests()[2]);
@@ -59,34 +52,32 @@ public class EmployeeSavingsTest extends TestCase
assertEquals(33.002, subject.calculateInterests()[11]);
}
- public void testGenerateMonthlySavings()
- {
+ public void testGenerateMonthlySavings() {
assertEquals(100.417, subject.generateMonthlySavings()[0]);
assertEquals(201.252, subject.generateMonthlySavings()[1]);
assertEquals(302.507, subject.generateMonthlySavings()[2]);
}
- public void testGetReport()
- {
- EmployeeSavings[] accounts = new EmployeeSavings[] {
- new EmployeeSavings("Elena", "Brandon"),
- new EmployeeSavings("Thomas", "Molson"),
- new EmployeeSavings("Hamilton", "Winn"),
- new EmployeeSavings("Suzie", "Sarandin"),
- new EmployeeSavings("Philip", "Winne"),
- new EmployeeSavings("Alex", "Trebok"),
- new EmployeeSavings("Emma", "Pivoto"),
- new EmployeeSavings("John", "Lenthen"),
- new EmployeeSavings("James", "Lean"),
- new EmployeeSavings("Jane", "Ostin"),
- new EmployeeSavings("Emily", "Car"),
- new EmployeeSavings("Daniel", "Hamshire"),
- new EmployeeSavings("Neda", "Bazdar"),
- new EmployeeSavings("Aaron", "Smith"),
- new EmployeeSavings("Kate", "Hen")
- };
+ public void testGetReport() {
+ EmployeeSavings[] accounts =
+ new EmployeeSavings[] {
+ new EmployeeSavings("Elena", "Brandon"),
+ new EmployeeSavings("Thomas", "Molson"),
+ new EmployeeSavings("Hamilton", "Winn"),
+ new EmployeeSavings("Suzie", "Sarandin"),
+ new EmployeeSavings("Philip", "Winne"),
+ new EmployeeSavings("Alex", "Trebok"),
+ new EmployeeSavings("Emma", "Pivoto"),
+ new EmployeeSavings("John", "Lenthen"),
+ new EmployeeSavings("James", "Lean"),
+ new EmployeeSavings("Jane", "Ostin"),
+ new EmployeeSavings("Emily", "Car"),
+ new EmployeeSavings("Daniel", "Hamshire"),
+ new EmployeeSavings("Neda", "Bazdar"),
+ new EmployeeSavings("Aaron", "Smith"),
+ new EmployeeSavings("Kate", "Hen")
+ };
String report = EmployeeSavings.getReport(accounts);
- for (EmployeeSavings account : accounts)
- assertTrue(report.contains(account.getFirstName()));
+ for (EmployeeSavings account : accounts) assertTrue(report.contains(account.getFirstName()));
}
}