小鱼宝宝 - 云代码空间
——
t java.util.*; |
public class UserInterface |
{ |
public static void main(String args[]){ |
Cards card0 = new Cards(); |
Cards card1 =new SavingsCard(); |
Cards card2 =new CreditCard(); |
int k=-1; |
Scanner scan = new Scanner(System.in); |
Scanner scan0 = new Scanner(System.in); |
Scanner scan1 = new Scanner(System.in); |
Scanner scan2 = new Scanner(System.in); |
do{ |
System.out.println("银行卡管理系统"); |
System.out.println("1.开卡"); |
System.out.println("2.存款"); |
System.out.println("3.取款"); |
System.out.println("4.查询余额"); |
System.out.println("0.退出系统"); |
System.out.println("请输入:"); |
k = scan.nextInt(); |
switch(k){ |
case(1):{ |
System.out.println("请输入开卡类型:\n1.储蓄卡\n2.信用卡"); |
int j; |
j = scan0.nextInt(); |
switch(j){ |
case(1):{ |
card0 = card1; |
System.out.println("您已开通储蓄卡!"); |
break; |
} |
case(2):{ |
card0 = card2; |
System.out.println("您已开通信用卡!"); |
break; |
} |
default:{ |
System.out.println("非法输入。"); |
break; |
} |
} |
break; |
} |
case(2):{ |
System.out.println("请输入存款金额:"); |
card0.saveMoney(scan1.nextDouble()); |
break; |
} |
case(3):{ |
System.out.println("请输入取款金额:"); |
card0.takeMoney(scan2.nextDouble()); |
break; |
} |
case(4):{ |
System.out.println("账户余额为:"+card0.getBalance()); |
break; |
} |
case(0):{ |
break; |
} |
default:{ |
System.out.println("非法输入。"); |
} |
} |
}while(k!=0); |