view.TextView.java

package view;


import java.awt.List;


import com.handson.common.SystemIn;


import exception.BalanceNotEnoughException;
import exception.LoginException;
import exception.RegisterException;


import biz.FileBank;
import biz.IBank;
import biz.Bank;
import biz.ListBank;


public class TextView {
IBank bank;
long thisid;
public void tools(){
System.out.println("********欢迎********");
System.out.println("******注册请输入1*****");
System.out.println("******登录请输入2*****");
System.out.println("******退出请输入3*****");
int i=SystemIn.readInt();
if(i==1){
reg();
}else if(i==2){
login();
}else if(i==3){
System.exit(0);
}else{
tools();
}
}

private void reg() {
System.out.println("请输入姓名>");
String name=SystemIn.readString();
System.out.println("请输入personId>");
String personId=SystemIn.readString();
System.out.println("请输入类型>");
int type=SystemIn.readInt();
System.out.println("请输入密码>");
String password=SystemIn.readString();
System.out.println("请再输入密码>");
String password2=SystemIn.readString();
try{
long result=bank.reg(password, password2, name, personId, type);
System.out.println(result+"注册成功:");
tools();
}catch(RegisterException e){
System.out.println(e.getMessage());
reg();
}

}
private void oper() {
System.out.println("存款请输入1");
System.out.println("取款请输入2");
System.out.println("查询余额请输入3");
System.out.println("退出请输入4");
System.out.println("返回主菜单请输入5");
int num=SystemIn.readInt();
if(num==1){
System.out.println("请输入存款额度>");
double money=SystemIn.readDouble();
bank.deposit(thisid, money);
oper();
}else if(num==2){
System.out.println("请输入取款额度>");
double money=SystemIn.readDouble();
try{
bank.withdraw(thisid, money);
oper();
}catch(BalanceNotEnoughException e){
System.out.println(e.getMessage());
tools();
}
}else if(num==3){
double balance=bank.selectBalance(thisid);
System.out.print("余额为>"+balance);
oper();
}else if(num==4){
System.exit(0);
}else if(num==5){
tools();
}else{
System.out.println("输入有误!");
oper();
}
}
private void login() {
System.out.println("请输入账号>");
long id=SystemIn.readInt();
System.out.println("请输入密码>");
String password=SystemIn.readString();
try{
long resule=bank.login(id, password);
System.out.println("登陆成功!");
this.thisid=resule;
oper();
}catch(LoginException e){
System.out.println(e.getMessage());
tools();
}
}


public TextView() {
super();
}


public TextView(Bank bank) {
super();
this.bank = bank;
}
public TextView(FileBank bank) {
super();
this.bank = bank;
}
public TextView(ListBank bank) {
super();
this.bank = bank;
}

}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
E/AndroidRuntime: FATAL EXCEPTION: Thread-3 Process: com.example.zfang.course2_1, PID: 31755 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6855) at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1075) at android.view.ViewGroup.invalidateChild(ViewGroup.java:5242) at android.view.View.invalidateInternal(View.java:13574) at android.view.View.invalidate(View.java:13538) at android.view.View.invalidate(View.java:13522) at android.widget.TextView.checkForRelayout(TextView.java:7354) at android.widget.TextView.setText(TextView.java:4479) at android.widget.TextView.setText(TextView.java:4336) at android.widget.TextView.setText(TextView.java:4311) at com.example.zfang.course2_1.fragment.MineFragment$1$1.showProgress(MineFragment.java:89) at com.example.zfang.course2_1.service.DownloadService$1.run(DownloadService.java:86) at java.lang.Thread.run(Thread.java:761) D/EGL_emulation: eglMakeCurrent: 0xa9d850c0: ver 2 0 (tinfo 0xa9d831d0) D/OpenGLRenderer: endAllActiveAnimators on 0x8c994500 (RippleDrawable) with handle 0xa9dff550 W/System.err: java.net.SocketTimeoutException: connect timed out W/System.err: at java.net.PlainSocketImpl.socketConnect(Native Method) W/System.err: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334) W/System.err: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196) W/System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) W/System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) W/System.err: at java.net.Socket.connect(Socket.java:586) W/System.err: at com.android.okhttp.internal.Platform.connectSocket(Platform.java:113) W/System.err:
06-12

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值