⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textview.java

📁 基本实现银行存取款功能
💻 JAVA
字号:
package view;
import biz.*;
import com.kettas.common.*;      

public class TextView {
	private IBank bank;
	private long currentId;
	public TextView(IBank bank){
		this.bank=bank;
	}
	public void showMain(){
		System.out.println("-------------------");
		System.out.println("1:OpenAccount");
		System.out.println("2:Login");
		System.out.println("3:Exit");
		System.out.println("-------------------");
		System.out.print("Please input your Selection");
		int choice=SystemIn.readInt();   
		switch(choice){     
			case 1:{ kaihu(); break;}
			case 2:{ denglu();  break;}
			case 3:{ System.exit(0);}
			default: showMain();
		}
		/*if (choice==1) kaihu();
		else if (choice==2) denglu();
		else if (choice==3) System.exit(0);
		else showMain();    */
	}
	
	public void kaihu(){
		int type;
		do{
			System.out.print("please input the account type:");
			type=SystemIn.readInt();
		}
		while(type!=0 && type!=1);
		
		System.out.print("please input password:");
		String pass=SystemIn.readString();
		
		System.out.print("please input password again:  ");
		String pass2=SystemIn.readString();
		
		System.out.print("please input name");
		String name=SystemIn.readString();
			
		System.out.print("please input personId: ");
		String personId=SystemIn.readString();
		this.currentId=bank.regist(name,pass, pass2,  personId, type);
		if(this.currentId!=  -1){
			System.out.println("Regist success, Your account Id is"+currentId);
			jiaoyi();  
	    }else{    
	    	System.out.println("Sorry,password not same!");
	    	showMain();
	    }
	}
	
	public void denglu(){
		System.out.print("Please input account id: ");
		long id=SystemIn.readInt();
		
		System.out.print("please input password: ");
		String pass=SystemIn.readString();
		
		
			this.currentId=bank.login(id, pass); 
			if( currentId != -1){
			    System.out.println("Welcome comeback "+currentId+" user");  
			   jiaoyi();
          }else{ 
          	     System.out.println("Sorry,password error");
          	     showMain();
          }
	}
	
	public void jiaoyi(){
		System.out.println("-------------------");
		System.out.println("1: Save");
		System.out.println("2: WithDraw ");
		System.out.println("3: Query Balance");
		System.out.println("4: Return Main");
		System.out.println("-------------------");
		System.out.print("Please input your selection: ");
		int choice=SystemIn.readInt();
		
		if (choice==1){
			System.out.print("please input money: ");  
			double money=SystemIn.readDouble();
			bank.save(this.currentId, money);
			jiaoyi();
		}
		else if (choice==2){
			System.out.print("please input money you want to withdraw: ");            
			double money=SystemIn.readDouble();
			bank.withdraw(this.currentId, money);
			jiaoyi();
		}
		else if (choice==3){
			double b=bank.queryBalance(this.currentId);
			System.out.println("your balance is "+b);          
			jiaoyi();
		}
		else if (choice==4){
			showMain();
		}
		else jiaoyi();
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -