zoukankan      html  css  js  c++  java
  • Java程序(银行账户管理)

    package 账户管理;

    import java.text.SimpleDateFormat;

    import java.util.Date;

    public class Zhanghu {

    private String _account;

    private String _name;

    private String _ID;

    private Date _accounTimet ;

    private double _balance;

    public Zhanghu(String account , String name , String ID , double balance ){

    this._account = account;

    this._name = name;

    this._ID = ID;

    this._accounTimet = new Date();

    this._balance = balance;

    }

    //存款

    public void deposit(double amount){

    _balance +=amount;

    System.out.println("成功存款:"+amount);

    checkAccount();

    }

    //取款

    public void withDrawal(double amount){

    if(amount > _balance){

    System.out.println("账户:"+this._account+" 卡上余额不足,取款失败!"+" " + "操作时间:"+this.getAccounTimet()+" " );

    return;

    }

    this._balance = this._balance - amount;

    System.out.println("成功取款:"+amount);

    checkAccount();

    }

    public void checkAccount(){

    System.out.println("账户:"+this._account+" 卡上余额为:"+_balance+" " + "操作时间:"+this.getAccounTimet()+" " );

    }

    public String getID() {

    return _ID;

    }

    public void setID(String iD) {

    _ID = iD;

    }

    public String getAccount() {

    return _account;

    }

    public void setAccount(String account) {

    this._account = account;

    }

    public String getName() {

    return _name;

    }

    public void setName(String name) {

    this._name = name;

    }

    public String getAccounTimet() {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");

    return sdf.format(this._accounTimet);

    }

    public void setAccounTimet(Date accounTimet) {

    this._accounTimet = accounTimet;

    }

    public double getBalance() {

    return _balance;

    }

    public void setBalance(double balance) {

    this._balance = balance;

    }

    }

     package 账户管理;

     public class Zhumain {

    public static void main(String[] args){

     Zhanghu account = new Zhanghu("123456", "张三","000001",500.00);

    account.checkAccount();

    account.deposit(100.00);

    account.withDrawal(400.00);

    }

    }

  • 相关阅读:
    黑马程序员系列第十篇 异常
    黑马程序员系列第八篇 IO(2)
    黑马程序员系列第九篇 类加载器
    黑马程序员系列第六篇 面向对象基础
    黑马程序员系列第七篇 IO(1)
    黑马程序员系列第五篇 集合(2)
    黑马程序员系列第四篇 集合(1)
    黑马程序员系列第三篇 反射
    vue 自定义指令集合
    计算图片缩放比例 使图片不变形
  • 原文地址:https://www.cnblogs.com/hjza/p/9012221.html
Copyright © 2011-2022 走看看