上周进行了Java的开学第一次测验,按要求做一个模拟ATM机功能的程序,实现存取款、转账汇款、修改密码、查询余额的操作。这次测验和假期的试题最大的不同还是把数组存储改成的文件存储,在听到老师说要用文件的时候,还是有种悔不当初的感觉的,假期里找的教程是有教文件的,当时想着假期给的试题仅要求数组,就偷了懒。这次测验的时候,看了一下文件的教程,不是怎么清楚怎么像题目那样使用文件,便放弃了这一部分,还是用的数组。这次测验还发现了自己的很多问题,特别是一些习惯上的问题。以前写的都是几十行的小程序,简单看下题目就知道该怎么做,而这次的测验却没那么小了。拿到题目的时候老师有叫过我们先构思,不要立刻动手,我看了题目想了一会儿,并没有很清楚的思路,只有一个模糊的想法,就开始动手,写到执行文件时就不太记得一开始的想法,写一会就看一会题目,翻翻刚写的代码,浪费了很多时间。写着写着就发现少了一些东西,又去前面加,后面都乱了。测试的时间从两个小时延长到两个半小时再到三个小时,可以说是很足了,但是我还是只实现了前面两个功能,也是和思路的混乱有关,当然更主要的是能力不足,暑假的学习太过应付了事,以后还是要努力才行,不能再贪玩了。

Account.java

 public class Account {

     private String accountID;      //账号
private String accountname;    //名称
private String operatedate; //操作时间
private int operatetype;
private String accountpassword; //密码
private int accountbalance; //账户余额
private int amount; //流水金额 public String getAccountID() {
return accountID;
}
public void setAccountID(String accountID) {
this.accountID = accountID;
}
public String getAccountname() {
return accountname;
}
public void setAccountname(String accountname) {
this.accountname = accountname;
}
public String getOperatedate() {
return operatedate;
}
public void setOperatedate(String operatedate) {
this.operatedate = operatedate;
}
public int getOperatetype() {
return operatetype;
}
public void setOperatetype(int operatetype) {
this.operatetype = operatetype;
}
public String getAccountpassword() {
return accountpassword;
}
public void setAccountpassword(String accountpassword) {
this.accountpassword = accountpassword;
}
public int getAccountbalance() {
return accountbalance;
}
public void setAccountbalance(int accountbalance) {
this.accountbalance = accountbalance;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
} Account( String accountID,String accountname,String accountpassword){
this.accountID = accountID;
this.accountname = accountname;
this.accountpassword = accountpassword;
accountbalance = 0;
} }

AccountManager.java

import java.util.Scanner;

public class AccountManager {

    Scanner in = new Scanner( System.in );
Account[] acc = new Account[1000];
int i=5;
int j,k;
int temp = 0; public void InterfaceAccount(){
acc[0] = new Account("20173445","刘**","123456");
acc[1] = new Account("20170001" ,"张三","387592");
acc[2] = new Account("20170002","李四","035432");
acc[3] = new Account("20170004","王五","830294");
acc[4] = new Account("20170005","赵六","208493");
temp=0;
String accountID;
System.out.println("**************************************************");
System.out.println(" 欢迎使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
System.out.print(" 请输入您的账号:");
accountID = in.next();
if( accountID.length() != 8 ){
System.out.println("**************************************************");
System.out.println("该卡不是工行账号");
InterfaceAccount();
}
else{
for( j=0; (j<i) && (temp==0); j++ ){
if( acc[j].getAccountID().equals( accountID ))
temp = 1;
}
if(temp==0){
System.out.println("**************************************************");
System.out.println("该账号不存在");
InterfaceAccount();
}
else{
j--;
InterfacePassword();
}
}
} public void InterfacePassword(){
String accountpassword;
int h=3;
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
while((h--)>0){
System.out.print(" 请输入您的密码:");
accountpassword = in.next();
if( acc[j].getAccountpassword().equals( accountpassword)){
InterfaceMain();
}
else{
System.out.println("**************************************************");
System.out.println("密码输入错误");
if( h==0){
System.out.println("**************************************************");
System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理");
InterfaceAccount();
}
}
}
} public void InterfaceMain(){
int operatetype;
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
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("**************************************************");
operatetype = in.nextInt();
acc[j].setOperatetype(operatetype);
switch(operatetype){
case 1:deposit();break;
case 2:withdraw();break;
}
} public void deposit(){ //存款
int amount;
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
System.out.println(" 请输入存款金额:");
amount = in.nextInt();
String s = String.valueOf(amount);
if( s.equals("q"))
InterfaceAccount();
else{
if( amount <= 0 ){
System.out.println("输入金额有误");
withdraw();
}
else{
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
System.out.println(" 当前账户存款操作成功");
acc[j].setAccountbalance( acc[j].getAccountbalance()+amount );
System.out.println(" 当前账户余额为:"+acc[j].getAccountbalance()+"元");
System.out.println("**************************************************");
s = in.next();
if( s.equals("q"))
InterfaceAccount();
}
}
} public void withdraw(){ //取款
int amount = 0;
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
System.out.println(" 当前账户每日可以支取2万元");
System.out.println(" 1、 100元");
System.out.println(" 2、 500元");
System.out.println(" 3、 1000元");
System.out.println(" 4、 1500元");
System.out.println(" 5、 2000元");
System.out.println(" 6、 5000元");
System.out.println(" 7、 其他金额");
System.out.println(" 8、 退卡");
System.out.println(" 9、 返回");
System.out.println("**************************************************");
temp = in.nextInt();
switch(temp){
case 1:amount=100;break;
case 2:amount=500;break;
case 3:amount=1000;break;
case 4:amount=1500;break;
case 5:amount=2000;break;
case 6:amount=5000;break;
case 7:{
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
System.out.println(" 请输入取款金额");
amount = in.nextInt();break;
}
default:break;
}
if( amount > acc[j].getAccountbalance() )
System.out.println("账户余额不足");
else{
System.out.println("**************************************************");
System.out.println(" 欢迎"+acc[j].getAccountname()+"使用中国工商银行自动柜员系统");
System.out.println("**************************************************");
System.out.println("当前账户取款操作"+amount+"元成功");
acc[j].setAccountbalance( acc[j].getAccountbalance()+amount);
System.out.println("当前账户余额为:"+acc[j].getAccountbalance()+"元");
System.out.println("**************************************************");
}
if( temp == 8 )
InterfaceAccount();
if(temp==9)
InterfaceMain();
} }

ATM.java

/*
* 信1705-1
* 20173445
* 刘
*/
public class ATM {
public static void main( String[] args){
AccountManager manager = new AccountManager();
manager.InterfaceAccount();
}
}

Java课堂测试01及感想的更多相关文章

  1. Java课堂测试--实现ATM的基本操作体会

    9月20的周四的Java课堂第一节课上就是有关于实现ATM的考试内容,在实现的过程中我了解到自己本身还是有很多的不足之处,例如在实现工程方面的相似性上面还有些许就的欠缺,再者就是回宿舍拿电源的原因导致 ...

  2. java课堂测试2(两种方式)

    实验源代码 这是不使用数组形式的源代码 /* 2017/10/10 王翌淞 课堂测试2 */import java.util.Scanner; public class Number { public ...

  3. JAVA语言课堂测试01源代码(学生成绩管理系统)

    package 考试; /*信1807-8 * 20183798 * 向瑜 */ import java.util.Scanner; //ScoreInformation 类 class ScoreI ...

  4. java课堂测试—根据模板完成一个简单的技术需求征集系统

    课堂上老师发布了一个页面模板要求让我们实现一个系统的功能,模仿以后后端的简单工作情况. 然后在这个模板的基础上,提供了一个注册的网页模板,接着点击注册的按钮,发现register里面调用了zhu/zh ...

  5. java课堂测试

       package 作业2; //信1805-1 杨一帆 20183608 public class ScoreInformation1 { private String stunumber; pr ...

  6. Java课堂测试——一维数组

    题目: 一个典型的流程是: 2. 用户这时候有两个选择2.1  按 单步执行 键, 在 GUI 看到你的程序是如何一步一步算出目前最大子数组的范围,当前计算到的临时子数组是在哪里,等等. 最好用不同的 ...

  7. JAVA课堂测试之一位数组可视化

    代码: package test;//求最大子数组 import java.util.Scanner; import javax.swing.JOptionPane; public class shu ...

  8. JAVA 课堂测试

    package ACC; /*信1705-2班 * 20173623 * 赵墨涵 */ public class Account { String accountID; String accountn ...

  9. java课堂测试样卷-----简易学籍管理系统

    程序设计思路:分别建立两个类:ScoreInformation类(用来定义学生的基本信息以及设置set和get函数)ScoreManagement类(用来定义实现学生考试成绩录入,考试成绩修改,绩点计 ...

随机推荐

  1. 发送邮件【文本-html】【图片】【邮件】【附件】

    依赖 <!-- https://mvnrepository.com/artifact/javax.mail/mail --> <dependency> <groupId& ...

  2. js导出excel:前端当前数据的导出

    网上找的库文件,同样做了修改.在导出的时候,有时候数据第一列和最后一列可能是复选框和操作按钮,这个是我们不需要的,加了这个的过滤 //table2excel.js /* * jQuery table2 ...

  3. Python 学习笔记---爬取海贼王动漫

    最近无聊整理的爬虫代码,可以自动爬取腾讯动漫的任意漫画,思路如下: 1. 先获取想下载的动漫url, 这里用了 getUrls ,直接获取动漫的最后一章 2. 然后进入到该动漫去获取要下载的图片url ...

  4. unity的inputField文本框赋值问题

    GameObject t = GameObject.Find("InputFieldT"); Text tt = t.transform.Find("Text" ...

  5. 初识Netty

    我们已经了解了Socket通信/IO/NIO/AIO编程,对于通信模型已经有了一个初步的认识,其实我们之前所学习的仅仅是一个模型,如果想把这些真正的用于实际工作中去,其实我们之前所学习的仅仅是一个模型 ...

  6. cgi fast-cgi php-fpm区别

    php-cli 是php在系统执行的程序,直接执行php文件: cgi和fast-cgi的区别1.cgi和fast-cgi都是php解析协议,负责解析服务器分发过来的php动态文件:cgi程序就会去解 ...

  7. 13-linux定时任务不起作用到的问题解决办法

    基本操作下面这篇: centos定时任务-不起作用- 没指明路径!!! 最大的问题是路径问题,以及权限问题. 用定时任务执行某些脚本是出现一系列问题,一步一步解决. 问题一:定时任务没反应: 查看日志 ...

  8. Swift 常量、变量、条件判断

    - 常量用 let ,变量用 var - // Optional为可选项,// 可用类型值 + ? 代替 let x: Optional = 10 let y: Int? = 5 print(x! + ...

  9. 线特征---EDLines原理(六)

    参考文献:EDLines: A real-time line segment detector with a false detection control ----Cuneyt Akinlar  , ...

  10. docker-ce-17.09 仓库的创建与使用

    docker仓库是集中存放镜像的地方,注册服务器是存放仓库的具体服务器,每个服务器上可以有多个仓库,每个仓库下面有多个镜像. 一.查找仓库中镜像 > docker search centos 二 ...