File tree Expand file tree Collapse file tree 5 files changed +35
-16
lines changed
src/com/java1995/banksystem Expand file tree Collapse file tree 5 files changed +35
-16
lines changed Original file line number Diff line number Diff line change 22<classpath >
33 <classpathentry kind =" src" path =" src" />
44 <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
5- <classpathentry kind =" lib" path =" D:/Program Files/ eclipse/lombok.jar" />
5+ <classpathentry kind =" lib" path =" D:/eclipse/lombok.jar" />
66 <classpathentry kind =" output" path =" bin" />
77</classpath >
Original file line number Diff line number Diff line change 44 * @author crazyxia
55 *
66 */
7- public class ICBClmpl implements IICBC {
7+ public class ICBCImpl implements IICBC {
88 //定义实现类,重写方法
99 double money =10000 ;//定义余额初始值
1010 double number ;//取钱数目
1111 double paymoney ;//支付金额
1212 public boolean testPassword (String word ){
1313 String str1 ="nihao" ;//默认密码
14- if (str1 .equals (word )){
15- System .out .println ("您输入的密码正确" );
14+ if (str1 .equals (word )){
1615 return true ;
17- }else {
18- System .out .println ("您输入的密码正确" );
19- return false ;
20-
16+ }else {
17+ return false ;//如果密码错误,使用return结束方法运行
2118 }
2219 }
2320 public double checkBalance (){//查看余额的方法
24- System .out .println ("money" );//返回余额值
21+ System .out .println ("您的余额为" + money );//返回余额值
2522 return money ;
2623 }
27- public boolean drawMoney (){//取钱的方法
24+ public boolean drawMoney (double number ){//取钱的方法
2825 if (money >=number ){
2926 money =money -number ;
3027 System .out .println ("余额为" +money );
@@ -34,13 +31,13 @@ public boolean drawMoney(){//取钱的方法
3431 return false ;
3532 }
3633 }
37- public void onlinePay (){
38- if (money >=number ){
39- money =money -number ;
34+ public void onlinePay (double paymoney ){
35+ if (money >=paymoney ){
36+ money =money -paymoney ;
4037 System .out .println ("余额为" +money );
4138
4239 }else {
43- System .out .println ("余额不足 " );
40+ System .out .println ("支付余额不足 " );
4441
4542 }
4643 }
Original file line number Diff line number Diff line change 66 */
77public interface IICBC extends IUnionpay {
88 //在满足银联接口的规则基础上(继承了银联接口),增加了在线支付功能。
9- public void onlinePay ();
9+ public void onlinePay (double paymoney );
1010
1111}
Original file line number Diff line number Diff line change 88public interface IUnionpay {
99 public boolean testPassword (String word );//定义密码检测的抽象方法
1010 public double checkBalance ();//定义查询余额的抽象方法
11- public boolean drawMoney ();//定义取钱的抽象方法
11+ public boolean drawMoney (double number );//定义取钱的抽象方法
1212
1313
1414}
Original file line number Diff line number Diff line change 1+ package com .java1995 .banksystem ;
2+
3+ import java .util .Scanner ;
4+
5+ public class TestICBC {
6+ public static void main (String [] args ){
7+ System .out .println ("请输入密码" );//用户密码录入
8+ Scanner sc =new Scanner (System .in );//
9+ String keyword =sc .nextLine ();
10+ IICBC icbc =new ICBCImpl ();//通过实现类和接口,创建一个icbc
11+ boolean b1 =icbc .testPassword (keyword );
12+ if (b1 ){
13+ icbc .checkBalance ();//显示余额
14+ System .out .println ("您输入的密码正确,请输入您要取金额" );
15+ double getmoney =sc .nextInt ();//从银行里取出的钱
16+ icbc .drawMoney (getmoney );
17+ }
18+ else {
19+ System .out .println ("您输入的密码不正确" );
20+ }
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments