java转账存钱代码 java 银行卡转账( 二 )


有三个行为: 存钱,取钱,查询
那么初始架构就是
public class IDmoney{
private String id;//卡号
private String money;//余额
....//些处为属性的get,set方法
public boolean inMoney(saveMoney){//存钱
//方法体
}
public boolean outMoney(saveMoney){//取钱
//方法体
}
public double selectMoney(saveMoney){//查询
//方法体
}
}
大致就是这样,至于方法里面的处理,得看你自己业务了..然后如果想自定义异常的话,你得去看看怎么自定义,和使用.
现在语言都是面向对象,所以在实际开发当中,尽量向对象看
如何用Java代码编写银行转账publicinterface ITransfer{/** 银行内部转账,从转出账号中扣除转账金额,给转入账号增加转账金额,需要保证以上两个操作* 要么同时成功,要么同时失败* fromAccountId 转出账号* outAccountId 转入账号* amount 转账金额*/publicvoid transferInner(String fromAccountId,String outAccountId,BigDecimal amount);/** 外部转账-转出,从转出账号中扣除转账金额* fromAccoutnId 转出账号* amount 转账金额*/publicvoid transferOut(String fromAccountId,String outAccountId,BigDecimal amount);/** 外部转账-转入,从转入账号中增加转账金额* toAccoutnId 转出账号* amount 转账金额*/publicvoid transerIn(String toAccountId,BigDecimal amount);}public interface ITransfer{ /* * 银行内部转账,从转出账号中扣除转账金额,给转入账号增加转账金额,需要保证以上两个操作 * 要么同时成功,要么同时失败 * fromAccountId 转出账号 * outAccountId 转入账号 * amount 转账金额 */ public void transferInner(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部转账-转出,从转出账号中扣除转账金额 * fromAccoutnId 转出账号 * amount 转账金额 */ public void transferOut(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部转账-转入,从转入账号中增加转账金额 * toAccoutnId 转出账号 * amount 转账金额 */ public void transerIn(String toAccountId,BigDecimal amount); }
java atm源代码解析先不说公司的保密协议
一个项目的代码能在这里全贴出来,还给你讲解的清楚?
、不过整个取款机流程是很简单的,就是用户进行不同的操作 , 
java 调用 JNI驱动硬件执行相应的操作,关键就是组织各种类型的报文,
通过DTU发送到银联那边,比如说支付报文,冲正报文,日结报文……
这些报文的组织一般java 也只管传入JNI 中C++组装好以后再调用 DTU驱动发送
java 这一块就是处理一些逻辑或者页面流转之类的、
代码是不可能贴的 , 保密协议还是有一定的约束力的
MyView myView = new MyView();
myView.anyView = this;
this.remove(this.xxPanel);
this.add(myView.getPanel());
this.repaint();
java 创建账户类,定义存钱取钱,查询余额方法,并自定义两个异常 取出比账户上多的钱 当小于0的钱存入import java.util.Scanner;
class InvalidDepositException extends Exception{ private static final long serialVersionUID = 1L; }
class AccountOverdrawnException extends Exception{private static final long serialVersionUID = 8704667444373838488L;}
public class count {
int money;
int countmoney;
public count() {
money = 0;
countmoney = 500;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public int getCountmoney() {
return countmoney;
}
public void setCountmoney(int countmoney) {
this.countmoney = countmoney;
}
public void inMoney(int t) throws InvalidDepositException {
if (t0) {
throw new InvalidDepositException();
}
}

推荐阅读