dimanche 14 janvier 2018

Running test cases in main method java

My developer partner and I need help as we need to test our class from our main. The problem we are having is coming up with ways to properly test the class that I created with proper test cases. We are not allowed to use any static methods except the main. The code we have so far is shown as is where we have become stumped looking for help. The main success we have had so far is the TotalCompInterest code runs so far. `package compoundInterest; package compoundInterest;

public class Main {

public static void main(String[] args) {
    CompInterest Debt = new CompInterest();
    System.out.println("lets see if this works");
    System.out.printf("$%.2f",Debt.TotalCompInterest(10,10_000,3.5));
    Main Z = new Main();
    System.out.println(Z.testYear());

}
public boolean testYear() {
    CompInterest T = new CompInterest();
    if() {
        return true;
    }
    return false;

}

} public class CompInterest {

public double TotalCompInterest
(double year, double principle, double rate) {

double amount = 0;
double timesComp = 1;

rate=(1+rate/100);

for(int i=0;i<year;i++)
timesComp*=rate;
amount=principle*timesComp;

double CompInt = amount-principle;
return amount;
}

} `

Aucun commentaire:

Enregistrer un commentaire