SHould create test case with java unit but keep gettig error code package model;
ID: 3555772 • Letter: S
Question
SHould create test case with java unit but keep gettig error
code
package model;
import java.util.Scanner;
/** using MVC model to create a account management program */
/** Design Model class*/
/** A model is an object representing data or even activity*/
public class AccountModel {
private final double euro = 0.72; /** set variables*/
private final double yuan = 6.2;
private String id;
private String name;
private double balance;
public AccountModel() {
super(); /**constructs a new instance of a this class*/
/** original amount of usd money*/
}
public String getId() { /** set and getting ID*/
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name; /** set and getting Name*/
}
public void setName(String name) {
this.name = name;
}
public double deposit(double amount)
{ /** design deposit method*/
System.out.print("Enter the amount of deposit: ");
Scanner SC = new Scanner(System.in);
amount=SC.nextDouble();
try{ balance= balance+amount;
} catch(Exception e){};
/** using exception for prevent runtime error*/
return balance;
}
public double withdraw(double amount)
{
System.out.print("Enter the amount of withdraw: ");
Scanner SC = new Scanner(System.in);
amount=SC.nextDouble(); /** design withdraw method*/
try{
balance= balance-amount;
} catch(Exception e){};
return balance;
}
public double editin_euro()
{ try{ /** translate usd to Euro*/
balance = balance * euro;}
catch(Exception e){};
return balance;
}
public double editin_yuan()
{
try{ /** translate usd to yuan*/
balance = balance / yuan;
} catch(Exception e){};
return balance;
}
public double getBalance()
{
return balance;
}
}
Test
package model;
import static org.junit.Assert.*;
import org.junit.Test;
/**
* @author secc
*
*/
public class AccountModelTest {
/**
* {@link model.AccountModel#getId()}? ?? ???? ???????.
*/
@Test
public void testGetId() {
AccountModel test= new AccountModel();
assertEquals("dp1202",test.getId());
// TODO
}
/**
* {@link model.AccountModel#getName()}? ?? ???? ???????.
*/
@Test
public void testGetName() {
AccountModel test= new AccountModel();
assertEquals("angela",test.getName());// TODO
}
/**
* {@link model.AccountModel#deposit(double)}? ?? ???? ???????.
*/
@Test
public void testDeposit() {
AccountModel test= new AccountModel();
assertEquals("depoist: 300.00",300,test.deposit(300));// TODO
}
/**
* {@link model.AccountModel#withdraw(double)}? ?? ???? ???????.
*/
@Test
public void testWithdraw() {
AccountModel model= new AccountModel();
assertEquals("withdraw: 100.00", 100, model.withdraw(100.00));// TODO
}
/**
* {@link model.AccountModel#editin_euro()}? ?? ???? ???????.
*/
@Test
public void testEditin_euro() {
AccountModel model= new AccountModel();
assertEquals("edit into Euro",model.editin_euro());// TODO
}
/**
* {@link model.AccountModel#editin_yuan()}? ?? ???? ???????.
*/
@Test
public void testEditin_yuan() {
AccountModel model= new AccountModel();
assertEquals("edit into Yuan",model.editin_yuan()); // TODO
}
/**
* {@link model.AccountModel#getBalance()}? ?? ???? ???????.
*/
@Test
public void testGetBalance() {
AccountModel model= new AccountModel();
assertEquals("balance: ", model.getBalance());// TODO
}
}
Explanation / Answer
DONE AS YOU REQUIRED
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.