在手机制作网站90设计官方网站

web/2025/10/4 12:57:43/文章来源:
在手机制作网站,90设计官方网站,网络舆情分析工具,中建八局第一建设公司网站目录 前言 项目规划#xff08;第二周#xff09; 具体实现 用户大类 AccountOperations接口 UserOperations接口 Operations类#xff08;实现类#xff09; Account类 User类 Area类 #xff08;父类#xff09; 货币大类 Money类#xff08;抽象类…目录 前言 项目规划第二周 具体实现 用户大类 AccountOperations接口 UserOperations接口 Operations类实现类 Account类 User类 Area类 父类 货币大类  Money类抽象类 操作界面 LoginInterface类 MainInterface类 RegistrationInterface类 三个界面的txt文档设计 后言 前言 上一周对ATM机模拟系统做了项目需求分析Java实现ATM机模拟系统week1-CSDN博客这周来做部分的实现。 项目规划第二周 完成操作页面展示 完成用户的登录。注册等用户基本操作 学习I/O要求用户数据必须持久化也可使用jdbcmysql 做好类的封装自定义异常处理 具体实现 用户大类 AccountOperations接口 该接口主要定义了对帐户进行的操作方法包括以下 创建账户登录账户退出账户保存账户信息调出账户信息 package Account.Operations.Method;import Account.Account; import Area.Area;import java.io.FileNotFoundException;public interface AccountOperations {public Account createAccount( Area area); // 创建账户public Account landAccount( String accountNumber, String cipher); // 登录账户public void logOut( Account account) throws FileNotFoundException; // 退出账户public void saveAccountInformation( Account account);public Account retrieveAccountInformation( String accountNumber, String cipher); }UserOperations接口 该接口主要定义了用户执行的操作方法目前包括以下 存款取款查询余额修改密码 package Account.Operations.Method;import Account.Account; import Currency.Money;public interface UserOperations {public void saveMoney( Money money, Account account); // 存钱public void withdraw( Money money, Account account); // 取钱public boolean checkBalance(Account account); // 查询余额public void changeCipher( Account account); // 修改密码 }Operations类实现类 该类用于实现以上两个接口的方法 package Account.Operations;import Account.Account; import Account.Operations.Method.AccountOperations; import Account.Operations.Method.UserOperations; import Area.Area; import Currency.Money; import OperationInterface.LoginInterface;import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.security.SecureRandom; import java.util.Scanner;public class Operations implements AccountOperations, UserOperations {Operations operations new Operations();LoginInterface loginInterface new LoginInterface();Overridepublic Account createAccount( Area area) {Scanner s new Scanner(System.in);// 给出账号System.out.println(输入本人身份证号码);String id s.next();// 给出手机号System.out.println(输入本人手机号);String mobileNumber s.next();StringBuilder ac new StringBuilder();ac.append(area.obtainNumber());SecureRandom num new SecureRandom();for( int i 0; i 11; i) {int t num.nextInt(10);ac.append(t);}String accountNumber ac.toString();// 输入密码String cipher s.next();// 创建一个账号并且初始化账号, 并且返回一个账号return new Account( accountNumber, cipher, 0.0, 0.0, 0, id, mobileNumber);}Overridepublic Account landAccount( String accountNumber, String cipher) {// 直接调用retrieveAccountInformation()方法调出相应账户Account account retrieveAccountInformation( accountNumber, cipher);if( account null ) {System.out.println(输入账号密码有误请重新输入);// 返回登录操作继续输入账号和密码Scanner s new Scanner(System.in);// 如果有什么其他操作 如 创建账号、修改密码操作 加这里/* ········· */// 利用递归函数重复输入直到能匹配到账号为止account landAccount( s.next(), s.next());}return account;}Overridepublic void logOut( Account account) throws FileNotFoundException {// 将目前的账号清空 重复利用account null;System.out.println(账号退出成功);// 退出账号后的后续操作写这里/* ······ *///返回登录界面loginInterface.loginInterface();//operations.landAccount() ; //}Overridepublic void saveAccountInformation( Account account) {// 为这个账户创建一个文本文档存放账户信息String address E:\\Account\\ account.getAccountNumber() .txt;File save new File(address);// 如果文件已经存在直接覆盖掉之前的信息保存if( save.exists() ) {try (FileOutputStream fileOut new FileOutputStream(address) ) {ObjectOutputStream oos new ObjectOutputStream(fileOut);oos.writeObject(account);oos.close();fileOut.close();System.out.println(账户信息保存成功);} catch (IOException e) {throw new RuntimeException(账户信息保存失败);}}// 如果文件不存在者创建一个新文件存放账户信息else {try {if( save.createNewFile() ) {try (FileOutputStream fileOut new FileOutputStream(address) ) {ObjectOutputStream oos new ObjectOutputStream(fileOut);oos.writeObject(account);oos.close();fileOut.close();System.out.println(账户信息保存成功);} catch (IOException e) {throw new RuntimeException(账户信息保存失败);}}} catch (IOException e) {throw new RuntimeException(e);}}}Overridepublic Account retrieveAccountInformation( String accountNumber, String cipher) {String address E:\\Account;// 读取指定路径目录File dictionary new File(address);// 将该目录中的文件读入到list中File[] list dictionary.listFiles();Account result null;if( list ! null ) {// 通过循环遍历目录中的文件进行逐个查找for( File t : list) {Path find Path.of(t.getAbsolutePath());String content null;try {content new String(Files.readAllBytes(find));} catch (IOException e) {throw new RuntimeException(e);}if( content.contains(accountNumber) content.contains(cipher) ) {// 将目标文件信息读取到一个Account对象中try (FileInputStream in new FileInputStream(address \\ t.getName())) {ObjectInputStream oos new ObjectInputStream(in);try {result (Account) oos.readObject();} catch (ClassNotFoundException e) {throw new ClassCastException(读取用户信息失败);}in.close();oos.close();} catch (IOException e) {throw new RuntimeException(e);}break;}}}else {System.out.println(目录为空);}return result;}Overridepublic void saveMoney(Money money, Account account) {Scanner s new Scanner(System.in);System.out.println(放入所存金额);account.setDeposit(account.getDeposit() money.MoneyExchange( money, s.nextInt()));// 这里也可以采用一个 try - catch 块处理 saveAccountInformation方法中遇到的异常目前未采用saveAccountInformation(account);System.out.println(存储成功);}Overridepublic void withdraw(Money money, Account account) {Scanner s new Scanner(System.in);System.out.println(输入要取出金额);int draw s.nextInt();if( draw account.getDeposit() ) {System.out.println(余额不足);}else {// 账户中的货币都是以人民币形式存储的所以要把取出存入的货币转化成人民币account.setDeposit(account.getDeposit() - money.MoneyExchange( money, s.nextInt()));}}Overridepublic void changeCipher(Account account) {Scanner s new Scanner(System.in);System.out.println(请输入本用户身份证号);String id s.next();System.out.println(请输入本用户手机号);String mobileNumber s.next();String address E:\\Account;File file new File(address);File[] list file.listFiles();if( list ! null ) {// 通过循环遍历目录中的文件进行逐个查找for( File t : list) {Path find Path.of(t.getAbsolutePath());String content null;try {content new String(Files.readAllBytes(find));} catch (IOException e) {throw new RuntimeException(e);}if( content.contains(id) content.contains(mobileNumber) ) {// 将目标文件信息读取到一个Account对象中try (FileInputStream in new FileInputStream(address \\ t.getName())) {ObjectInputStream oos new ObjectInputStream(in);try {Account result (Account) oos.readObject();System.out.println(请输入新密码由六位数组成);result.setCipher(s.next());System.out.println(密码更改成功);// 保存信息saveAccountInformation(result);} catch (ClassNotFoundException e) {throw new ClassCastException(更改密码时读取用户信息失败);}in.close();oos.close();} catch (IOException e) {throw new RuntimeException(e);}break;}}}else {System.out.println(目录为空);}}public boolean checkBalance(Account account) {Account result retrieveAccountInformation( account.getAccountNumber(), account.getCipher());if ( result ! null ) {System.out.println(账户余额为 result.getDeposit() RMB);return true;}else {System.out.println(账户余额查询失败请重新输入账号和密码);return false;// 如果查询失败可根据用户选择进行继续查询这里通过返回值判断是否查询成功}} }Account类 该类是对账户的定义包括了账户应当具有的属性 包括但不限于 账号密码手机号余额年利率待商榷时间待商榷用户id package Account;import java.io.Serializable;// 因为要实现账户保存所以要接Serializable接口 public class Account implements Serializable {private String accountNumber;private String cipher;private Double deposit;private Double annualInterestRate;private int time;private final String id;private final String mobileNumber;public Account(String accountNumber, String cipher, Double deposit, Double annualInterestRate, int time, String id, String mobileNumber) {this.accountNumber accountNumber;this.cipher cipher;this.deposit deposit;this.annualInterestRate annualInterestRate;this.time time;this.id id;this.mobileNumber mobileNumber;}Overridepublic String toString() {return Account{ accountNumber accountNumber \ , cipher cipher \ , deposit deposit , annualInterestRate annualInterestRate , time time };}private int getTime() {return time;}public String getAccountNumber() {return accountNumber;}public String getCipher() {return cipher;}public Double getAnnualInterestRate() {return annualInterestRate;}public Double getDeposit() {return deposit;}public void setAccountNumber(String accountNumber) {this.accountNumber accountNumber;}public void setDeposit(Double deposit) {this.deposit deposit;}public void setAnnualInterestRate(Double annualInterestRate) {this.annualInterestRate annualInterestRate;}public void setTime(int time) {this.time time;}public void setCipher(String cipher) {this.cipher cipher;}public String getId() {return id;}public String getMobileNumber() {return mobileNumber;} }User类 该类是面向用户的主要实现了用户使用系统时的操作逻辑通过用户输入的操作数来执行对应的操作。 package User;import Account.Account; import Account.Operations.Operations; import OperationInterface.LoginInterface; import OperationInterface.MainInterface; import OperationInterface.RegistrationInterface;import java.io.FileNotFoundException; import java.util.Scanner;import static java.lang.System.exit;public class User {public void userOperation() throws FileNotFoundException {// 跳出首页画面提示用户/* ······· */Scanner s new Scanner(System.in);Account account null;Operations operation new Operations();System.out.println(输入 1 登录账户 输入 2 创建新账户 );int userOperation s.nextInt();if(userOperation 1){LoginInterface loginInterface new LoginInterface();loginInterface.loginInterface();Operations operations new Operations();//调用登录方法//operations.landAccount(); ////如何判断登录成功成功则进入主界面MainInterface mainInterface new MainInterface();mainInterface.mainInterface(); //展示主界面}else if (userOperation 2){RegistrationInterface registrationInterface new RegistrationInterface();registrationInterface.registrationInterface();Operations operations new Operations();//调用创建账户方法//operations.createAccount(); }else {System.out.println(您进行的操作不合法);}// 以下可以根据页面直接加操作/* ············· */}public void mainInterfaceOperation(){//主界面操作Scanner scanner new Scanner(System.in) ;Operations operations new Operations();int n scanner.nextInt();if (n 1){//调用存款方法//operations.saveMoney(); //}else if(n 2){//调用取款方法//operations.withdraw(); //}else if(n 3){//调用查询余额方法//operations.checkBalance() ;///}else if(n 4){//调用货币交换方法 未实现}else if(n 5){//调用修改密码方法//operations.changeCipher(); }else if(n 6){//调用操作日志查询方法 未实现}else if(n 7){//调用退出账户方法返回登录界面//operations.logOut(); ///}else if(n 8){//退出系统即终止程序运行exit(0) ;}} }Area类 父类 在创建账户时需要根据用户所在地区给出前几位数字我们用一个Area父类来实现这一功能每个不同的地区均是其子类 package Area;public class Area {public String name;public Area(String name) {this.name name;}public String obtainNumber() {return null;} }货币大类  本周货币大类不在需要实现的范围内故只进行了简单的架构 Money类抽象类 主要实现货币交换的方法每个不同的币种均是其子类 package Currency;public abstract class Money {public Double exchangeRate; // 汇率, 人民币与该货币的比public abstract Double MoneyExchange( Money money, int num); // 某货币交换成人民币public abstract Double ExchangeMoney( Money money, int num);// 人民币交换成某货币 }操作界面 目前实现了三个界面 登录界面注册界面主界面 界面的实现极其简单无非是几个文件创建和输出的事情罢了。 LoginInterface类 package OperationInterface;import java.io.*;public class LoginInterface {public void loginInterface() throws FileNotFoundException {File file new File(Login.txt); //创建File类对象并给出其相对路径否则默认创建在当前路径下if (file.exists()) { //调用exists方法判断文件是否存在fileInput(file); //如已存在直接打开} else { //如不存在执行创建操作try {file.createNewFile();fileInput(file);} catch (Exception e) {System.out.println(系统故障);}}}private void fileInput(File file) {FileReader f null;//文件读取对象BufferedReader f1 null;//字符流对象try {f new FileReader(file);f1 new BufferedReader(f);//循环打印cc文件中的每行数据String str null;while ((str f1.readLine()) ! null) {System.out.println(str);}} catch (Exception e) {System.out.println(系统故障);} finally {try {f1.close();f.close();} catch (Exception e2) {System.out.println(系统故障);}}} }MainInterface类 package OperationInterface;import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader;public class MainInterface {public void mainInterface() throws FileNotFoundException {File file new File(Main.txt); //创建File类对象并给出其相对路径否则默认创建在当前路径下if (file.exists()) { //调用exists方法判断文件是否存在fileInput(file); //如已存在直接打开} else { //如不存在执行创建操作try {file.createNewFile();fileInput(file);} catch (Exception e) {System.out.println(系统故障);}}}private void fileInput(File file) {FileReader f null;//文件读取对象BufferedReader f1 null;//字符流对象try {f new FileReader(file);f1 new BufferedReader(f);//循环打印cc文件中的每行数据String str null;while ((str f1.readLine()) ! null) {System.out.println(str);}} catch (Exception e) {System.out.println(系统故障);} finally {try {f1.close();f.close();} catch (Exception e2) {System.out.println(系统故障);}}} }RegistrationInterface类 package OperationInterface;import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader;public class RegistrationInterface {public void registrationInterface() throws FileNotFoundException {File file new File(Registration.txt); //创建File类对象并给出其相对路径否则默认创建在当前路径下if (file.exists()) { //调用exists方法判断文件是否存在fileInput(file); //如已存在直接打开} else { //如不存在执行创建操作try {file.createNewFile();fileInput(file);} catch (Exception e) {System.out.println(系统故障);}}}private void fileInput(File file) {FileReader f null;//文件读取对象BufferedReader f1 null;//字符流对象try {f new FileReader(file);f1 new BufferedReader(f);//循环打印cc文件中的每行数据String str null;while ((str f1.readLine()) ! null) {System.out.println(str);}} catch (Exception e) {System.out.println(系统故障);} finally {try {f1.close();f.close();} catch (Exception e2) {System.out.println(系统故障);}}} } 三个界面的txt文档设计 //登录界面 登录账号: 密码//注册界面注册请输入身份证号: 请输入手机号: 请输入密码://主界面欢迎1.存款 2.取款 3.查询余额 4.货币交换 5.更改密码 6.操作日志查询 7.退出账户 8.退出系统后言 本周主要实现了用户的部分基本操作采用的主要手段为文件操作文件的写入与读取也有博客记录Java文件操作从创建文件到简单输入输出流-CSDN博客用于存储数据设计操作界面等。在和朋友进行合作开发的过程中我们也遇到了许多问题比如当我们分析完项目需求后双方就开始着手写代码实现却没有提前沟通好代码逻辑导致虽然写了注释互相读代码时也遇到了不小的障碍所以大家千万别学我们 新手上路水平有限如有错误还望海涵并指出 与君共勉

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/86788.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

泰州网站建设方案优化安徽建设厅网站考勤

数据库是什么 数据库是一种用来存储数据的仓库,是一种高效存储和处理数据的介质(载体)。我们通常口中所说的数据库指的是数据库管理系统(DBMS),是一种用于方便管理数据库的软件。 数据库的分类 根据存储…

网站设计知名企业剑三做月饼活动网站

是cocoaChina网站上下载的知识点整理,共669个知识点,我花了点时间给文件全部做了重命名,这样用来查阅或者选择性的学习会有些帮助。 文件放在115网盘,下载地址:http://115.com/file/bhkqjlx2#cocoaChina整理知识点.rar…

网站点击量在哪里看网站推广方法有哪些

目录 stack类介绍 stack类定义 stack类常见构造函数 stack数据操作 empty()函数 size()函数 top()函数 push()函数 pop()函数 swap()函数 stack类介绍 stack是一种容器适配器,专门用在具有后进先出操作的上下文环境中,其删除只能从容器的一端…

做特价网站百度云网站建设视频教程

10.1 文件I/O操作概述在Linux系统中,文件I/O操作可以分为两类,一类是基于文件描述符的I/O操作,另一类是基于数据流的I/O操作。10.1.1 文件描述符简介在文件操作一章中,也经常提到文件描述符这个概念。所谓文件描述符,就…

济南网站建设制作设计北京引流推广公司

为什么80%的码农都做不了架构师?>>> 1、图形简介 与html5不同,Raphael提供了以下基本图形:矩形、圆形、椭圆形(html5只有矩形)。 Paper.rect(x,y,width,height,r):绘制矩形; 参…

海宁市建设局官方网站6APP编辑WordPress

前言 在说到对图片资源进行优化时,那就不得不提到图片预加载和图片懒加载,可能很多朋友都了解这两者,但是一直没有很清晰的概念,以及什么时候用,用在什么场景下,今天就来详细的了解一下吧! 图…

网站建网站建设做水利网站需要多少钱

一、前言 K8S经过多年的发展,构建了云原生的基石,成为了云原生时代的统治者。我将用三个博客系列全面,循序渐进的介绍K8S相关知识。 初级入门系列,主要针对K8S初学者,以及希望对K8S有所了解的研发人员,重点…

怎么做汽车网站php和什么语言做网站

最近富文本编辑器jodit终于更新发布到了4.0版本,加入了css变量、有更好的typescript支持,截止发文时的版本是:4.0.5,看到有了新版本于是便想着将本地项目中的jodit版本也进行升级,琢磨着再丰富和添加一些功能&#xff…

建设六马路小学 网站网站集约化建设的好处

1.概要 初步搭建了Layout界面的布局,其中包括左侧导航栏及其路由功能,和右侧头、体、脚部分的大致排版。最后在头部分中的昵称与头像替换成动态数据。 2.Layout主页布局 文件地址:src\views\Layout.vue 2.1 script行为模块 从elementUI中…

建站排行榜有哪些站内推广的方式

文章目录基本介绍入门步骤执行原理Servlet 生命周期线程安全问题解决方式Servlet 注解配置Servlet 继承与实现体系基本介绍 servlet,server applet,服务器端小程序 servlet 是一个接口,定义了 Java 类被浏览器访问(tomcat 识别&…

建立一个网站需要多少钱?网站网络营销外包

uni-app 微信小程序调试不更新问题解决指南 在使用 uni-app 开发微信小程序时,可能会遇到代码修改后无法更新或者不生效的问题。这种现象常见于调试阶段,通常与缓存、编译或代码错误有关。 本文将详细分析调试过程中常见的“不更新”问题,并…

dede能建立手机网站吗计算机做网站开题报告

目录: SpringMVC 的 “整合支持” ( 引入"Web依赖启动器",几乎可以在无任何额外的配置的情况下进行"Web开发")1.SpringMVC "自动配置" 介绍 ( 引入Web依赖启动器"后,SpringBoot会自动进行一些“自动配置”&#xff0…

专业做面膜的网站在线玩网页游戏h5网站大全

光猫就是“光modem”,是指将光以太信号转换成其它协议信号的收发设备,也是起着调制解调的作用。光猫也称为单端口光端机,该设备作为本地网的中继传输设备,适用于基站的光纤终端传输设备以及租用线路设备。而对于多口的光端机一般会…

长沙微网站开发公司网站域名注册流程

一、实验目的 (1)了解图像增强的目的及意义,加深对图像增强的感性认识,巩固所学的图像增强的理论知识和相关算法。 (2)熟练掌握低通、高通、带通、同态滤波器的使用方法,明确不同性质的滤波器…

怎样建设自已的网站英文网站收录提交

const 是 C 语言中的一个关键字,它表示一个对象或变量是常量,即在其生命周期内不可更改。在 C 语言中,const 有多种用法,可以提高代码的可读性和安全性。这里列举了一些关于 const 的常见用法: 声明常量变量&#xff…

ai特效字体网站设计方案步骤

我的 index.jsp 代码是这样 现在每次启动 访问的都是index.jsp 这也是它的默认配置 我这里写了一个 WebServlet 代码是这样 简单可以理解为 我们定义了WebServlet 访问路径为1cginServlet 其中在request作用域中 定义了一个userName值为 欢迎来到jsp世界 然后 跳转向 page.j…

网站建设教程开源代码下载手机网站建设ppt

文 | Mike Shou知乎(ID:Showthem)本文已获作者授权,禁止二次转载0. 写在前面「 开始写这边总结的时候是三月,纽约成了疫情震中,看着新闻报道里的中央公园,中国城,第五大道,往事浮现&…

网站建设纯免费官网太原seo推广优化

在手机侧与穿戴设备侧构建应用到应用的通信隧道,用于收发应用自定义的报文消息以及文件。实现手机应用和穿戴设备应用间的交互,为用户提供分布式场景和体验。比如手机应用发送音频文件到穿戴设备侧应用,实现在穿戴设备侧应用上播放音乐&#…

神奇网站基于php网站建设论文

基于java的SSM框架Vue实现大学生兼职信息网站演示 摘要 21世纪的今天,随着社会的不断发展与进步,人们对于信息科学化的认识,已由低层次向高层次发展,由原来的感性认识向理性认识提高,管理工作的重要性已逐渐被人们所认…

网站备案 修改新建网页的方法有哪些

var str "今天是星期" "日一二三四五六".charAt(new Date().getDay());alert(str); 转载于:https://www.cnblogs.com/lccnblog/p/5902525.html