控制台输入,没反应。谢谢·
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();
}
}
输出:
1.存款 2.取款 3.退出
请输入您的选项:1
请输入存入钱数:100
****当前余额100.0****
挺好用的呀