日期:2014-05-20 浏览次数:21103 次
package chapter13;
import java.util.Scanner;
/**
* 银行类
* @author lenovo
*
*/
public class Bank {
double balance=0.0;
Scanner console = null;
public void bankMenu(){
System.out.println("1.存款 2.取款 3.退出");
System.out.print("请输入您的选项:");
console = new Scanner(System.in);
int chose = console.nextInt();
switch(chose){
case 1: deposit();break;
case 2: drawing();break;
case 3: exitMenu();break;
}
}
private void exitMenu() {
}
private void drawing() {
// TODO Auto-generated method stub
console = new Scanner(System.in);
System.out.print("请输入存入钱数:");
balance=balance+console.nextDouble();
System.out.println("****当前余额"+balance+"****");
}
private void deposit() {
// TODO Auto-generated method stub
console = new Scanner(System.in);
System.out.print("请输入存入钱数:");
balance=balance+console.nextDouble();
System.out.println("****当前余额"+balance+"****");
}
}
package chapter13;
import static org.junit.Assert.*;
import org.junit.Test;
public class BankTest {
@Test
public void testBankMenu() {
Bank bank = new Bank();
bank.bankMenu();
}
}