资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
界面:package 个人收支管理系统;import java.util.Scanner;public class Test public static void main(String args) Manager b = new Manager();boolean bRun = true;while (bRun) System.out.println(*);System.out.println(*个人收支管理 *);System.out.println( );System.out.println(*1.注册*);System.out.println(*2.登录*); System.out.println(*3.收入*); System.out.println(*4.支出*); System.out.println(*5.查询与统计*); System.out.println(*6.写读取文件*);System.out.println(*7.注销用户*); System.out.println(*8.退出*);Scanner s = new Scanner(System.in);int userPrint = s.nextInt();switch (userPrint) case 1:b.register();break;case 2:b.login();break;case 3:b.save();break;case 4:b.get();break;case 5:b.find();break;case 6:b.f(); break;/*case 7: b.读出();break;*/case 7:b.exit();break;case 8:bRun = false;break;default:主方法: package 个人收支管理系统;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.Reader;import java.io.Writer;import java.util.ArrayList;import java.util.Date;import java.util.LinkedList;import java.util.Scanner;import java.util.Vector;public class Manager LinkedList list = new LinkedList();ArrayListVector allUser = null;Vector currentUser = null;Date date= new Date();/* * 声明Vector * 第1个元素存储 卡号,下标为0 * 第2个元素存储 密码,下标为1 * 第3个元素存储用户的余额,下标为2 * */public Manager() allUser = new ArrayListVector();public void register() System.out.println(请输入注册信息,格式为 卡号-密码-开卡额);Scanner s = new Scanner(System.in);String information = s.next();String infos = information.split(-);/实例化一个Vector表示新的用户Vector v = new Vector();v.add(infos0);v.add(infos1);v.add(infos2);allUser.add(v);public void login() System.out.println(请输入您要登录的帐号:);Scanner s = new Scanner(System.in);int userPrintCode = s.nextInt();for (int i = 0; i allUser.size(); i+) Vector findUser = allUser.get(i);Object findCodeObj = findUser.get(0);String findCodeStr = findCodeObj.toString();int findCodeInt = Integer.parseInt(findCodeStr);if (findCodeInt = userPrintCode) boolean bLogin = validatePassword(findUser.get(1);if (bLogin) System.out.println(登录成功);/如果登录成功,将成员变量currentUser赋值为findUser(卡号和密码都校验成功的用户)currentUser = findUser; else System.out.println(登录失败);/* * 该方法用于校验 * 已经查到的卡号的密码是否正确 * 参数password 已经查到的用户存储的密码 * */public boolean validatePassword(Object password) /用户输入密码System.out.println(请输入密码);Scanner s = new Scanner(System.in);int userPrintPw = s.nextInt();String passwordStr = password.toString();int passwordInt = Integer.parseInt(passwordStr);/如果用户输入的密码,和刚才传入的对应卡号的密码一致if (userPrintPw = passwordInt) return true; else return false;public void save() if (currentUser = null) System.out.println(请先登录); else /卡中余额(在执行收入之前的卡中的钱)Object beforeMoney = currentUser.get(2);/请输入您要收入的额度 Scanner s = new Scanner(System.in);System.out.println(date.toLocaleString();System.out.println(请输入顺序号:);String a=s.next(); list.add(a);System.out.println(请输入日期);String data=s.next(); list.add(data);System.out.println(请输入摘要内容:);String zaiyao=s.next();list.add(zaiyao);System.out.println(请输入收入额度:);int userPrintMoney = s.nextInt();int before = Integer.parseInt(beforeMoney.toString();/总额 = 之前的余额 + 用户这次的收入额度int sum = before + userPrintMoney;/把总额再存储到当前的用户信息中(位置是第3个,下标为2)currentUser.set(2, sum); System.out.println(当前额度:+currentUser.set(2, sum); public void get() if (currentUser = null) System.out.println(请先登录); else System.out.println(请输入您要支出的额度);Scanner s = new Scanner(System.in);int userPrintMoney = s.nextInt();Object beforeMoney = currentUser.get(2);int before = Integer.parseInt(beforeMoney.toString();if (before userPrintMoney)
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号