帐户管理
Posted 马蓉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了帐户管理相关的知识,希望对你有一定的参考价值。
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+" 卡上余额不足,取款失败!"+"\n" + "操作时间:"+this.getAccounTimet()+"\n" );
return;
}
this._balance = this._balance - amount;
System.out.println("成功取款:"+amount);
checkAccount();
}
public void checkAccount(){
System.out.println("账户:"+this._account+" 卡上余额为:"+_balance+"\n" + "操作时间:"+this.getAccounTimet()+"\n" );
}
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);
}
}
结果为:
账户:123456 卡上余额为:500.0
操作时间:2018:05:01 16:33:23
成功存款:100.0
账户:123456 卡上余额为:600.0
操作时间:2018:05:01 16:33:23
成功取款:400.0
账户:123456 卡上余额为:200.0
操作时间:2018:05:01 16:33:23
以上是关于帐户管理的主要内容,如果未能解决你的问题,请参考以下文章
BAT-把当前用户以管理员权限运行(用户帐户控制:用于内置管理员帐户的管理员批准模式)