ATM



package cn.atm;

//声明银行类
public class Bank {
 // 生命用户信息的数据
 private String[] names = new String[3];
 private String[] pwds = new String[3];
 private double[] moneys = new double[3];
 private int index = 0;

 // 提供注册信息
 public void reg(String name, String pwd, double money) {
  // 将所有信息保存到数组中
  names[index] = name;
  pwds[index] = pwd;
  moneys[index] = money;
  index++;
 }

 // 登录
 public boolean login(String name, String pwd) {
  boolean boo = false;
  for (int i = 0; i < index; i++) {
   // 遍历判断
   if (names[i].equals(name) && pwds[i].equals(pwd)) {
    boo = true;
    break;

   }
  }
  return boo;
 }
}






package cn.atm;

import java.util.Scanner;

//与用户尽心交流
public class ATM {
 // 声明 Scanner
 Scanner sc = new Scanner(System.in);
 // 声明 ban
 Bank bank = new Bank();

 public static void main(String[] args) {
  ATM atm = new ATM();
  atm.option();
 }

 public void option(){
  while(true){
   System.out.println("plz enter your choose");
   System.out.println("1:login\n2:reg\n0:exit");
   String op = sc.nextLine();
   switch (op) {
   case "1":
    login();
    break;
   case"2":
    reg();
    break;
   case"0";
   System.out.println("再见");
   break one;
   
   default:
    break;
   }
  }
 }
 public void reg(){
  System.err.println("请输入名字");
  String name = sc.nextLine();
  System.err.println("请输入密码");
  String pwd = sc.nextLine();
 System.err.println("请输入金额");
 String money = sc.nextLine();
 }
 public void login(){
  System.err.println("请输入名字");
  String name = sc.nextLine();
  System.err.println("请输入密码");
  String pwd = sc.nextLine();
  boolean boo = bank.login(name, pwd);
  if(boo){
   System.err.println("你登陆成功了");
   menu();
  }
 }
 public void menu(){
  while(true){
   System.out.println("1:\n2:\n");
   String op = sc.nextLine();
   //todo
  }
  
  }
 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值