Account:

package banking2;

//账户
public class Account {
private double balance;// 账户余额 public Account(double init_balance) {
balance = init_balance;
} public double getBlance() {
return balance;
} // 存钱
public void deposit(double amt) {// amt 要存的额度
balance += amt;
} // 取钱
public void withdraw(double amt) {// amt:要取得额度
if (balance >= amt) {
balance -= amt;
} else {
System.out.println("余额不足");
}
}
}

Customer:

package banking2;

public class Customer {
private String firstName;
private String lastName;
private Account account; public Customer(String f, String l) {
firstName = f;
lastName = l;
} public String getFirstName() {
return firstName;
} public String getLastName() {
return lastName;
} public Account getAccount() {
return account;
} public void setAccount(Account acct) {
account = acct;
}
}

TestBanking2:

package TestBanking;

/*
* This class creates the program to test the banking classes.
* It creates a new Bank, sets the Customer (with an initial balance),
* and performs a series of transactions with the Account object.
*/
import banking2.Account;
import banking2.Customer; public class TestBanking2 { public static void main(String[] args) {
Customer customer;
Account account; // Create an account that can has a 500.00 balance.
account = new Account(500.00);
System.out.println("Creating the customer Jane Smith.");
customer = new Customer("Jane", "Smith"); customer.setAccount(account);
// code
System.out.println("Creating her account with a 500.00 balance.");
// code
customer.getAccount().withdraw(150);
System.out.println("Withdraw 150.00"); // code
customer.getAccount().deposit(22.50);
System.out.println("Deposit 22.50");
// code
customer.getAccount().withdraw(47.62);
System.out.println("Withdraw 47.62");
// code
// Print out the final account balance
System.out.println("Customer [" + customer.getLastName() + ", " +
customer.getFirstName()+ "] has a balance of " + customer.getAccount().getBlance());
}
}

Bank2的更多相关文章

  1. STM32F429 LCD程序移植

    STM32F429自带LCD驱动器,这一具有功能给我等纠结于屏幕驱动的程序员带来了很大的福音.有经验的读者一定有过这样的经历,用FSMC驱动带由控制器的屏幕时候,一旦驱动芯片更换,则需要重新针对此驱动 ...

  2. ZYNQ学习之——MIO

    1.GPIO基础知识 Zynq7000 系列芯片有 54 个 MIO(multiuse I/O) ,它们分配在 GPIO 的 Bank0 和Bank1 隶属于 PS 部分, 这些 IO 与 PS 直接 ...

  3. ibatis map

    <select id="selectBank2" parameterClass="java.util.Map" resultClass="jav ...

  4. MVVM架构~knockoutjs系列之包括区域级联列表的增删改

    返回目录 这个例子我做了几次,之前总是有BUG,目前测试后,确定没有BUG才发上来的,主要功能是实现“我的银行”模块的增删改的功能,这个里面包括了级联列表的区域选择,这部分是难点,在开发过程中,我们应 ...

  5. S5PV210的内存分配研究分析

    S5PV210内存一般会使用SDRAM和DDR2 (DDR SDRAM),SDRAM的uboot启动网络已经有很多资料的,对于DDR2还有有很多疑惑,如果有错误的地方,请大家一定指出,醍醐灌顶,不胜感 ...

  6. Bank homework 10 2016 4 25

    #include<iostream>#include<string>using namespace std;class Bank { public: Bank(string _ ...

  7. java笔记--用ThreadLocal管理线程,Callable<V>接口实现有返回值的线程

    用ThreadLocal管理线程,Callable<V>接口实现有返回值的线程 ThreadLocal在我的笔记"关于线程同步"的第5种方式里面有介绍,这里就不多说了. ...

  8. 《Java核心技术卷一》笔记 多线程同步(底层实现)

    一.锁的基本原理 多个线程同时对共享的同一数据存取 ,在这种竞争条件下如果不进行同步很可能会造成数据的讹误. 例如:有一个共享变量int sum=0, 一个线程正调用 sum+=10,另一个线程正好也 ...

  9. FSMC stm32

    1.FSMC机制 FSMC(Flexihie Static Memory Controller,可变静态存储控制器)是STM32系列中内部集成256 KB以上FlaSh,后缀为xC.xD和xE的高存储 ...

随机推荐

  1. django源码解读——runserver分析

    开始之前建议先参考一下这篇文章:https://blog.csdn.net/qq_33339479/article/details/78862156class Command(BaseCommand) ...

  2. Dreamoon Likes Coloring(模拟+构造)

    \(这题刚好撞到我的思路了,但是因为模拟......我看了几十遍测试数据....\) $首先当\sum_^m$小于n时一定无解 大于呢?那我们就要浪费一些区间(覆盖一些点,也就是多出来的点) 但是又不 ...

  3. dp cf 20190615

    A. Timofey and a tree 这个不算是dp,就是一个思维题,好难想的思维题,看了题解才写出来的, 把点和边分开,如果一条边的两个点颜色不同就是特殊边,特殊边两边连的点就叫特殊点, 如果 ...

  4. 基于3D NAND层差异的固态盘请求调度算法研究立项 报告

    Abstract SSD(Solid State Drive),因其超高的读写性能,以及价格的走低趋势逐渐占据市场,为人们带来更好的用户体验,也为企业级的高并行业务需要提供了一定支持,近几年来SSD的 ...

  5. STM32 TIM1高级定时器配置快速入门

    layout: post tags: [STM32] comments: true 文章目录 layout: post tags: [STM32] comments: true 重点内容 时基单元 计 ...

  6. python重试次数装饰器

    目录 重试次数装饰器 重试次数装饰器 前言, 最近在使用tornado框架写Restful API时遇到很多的问题. 有框架的问题, 有异步的问题. 虽然tornado 被公认为当前python语言最 ...

  7. python爬虫-vmgirls-正则表达式

    概述 本次爬虫任务是爬取图片网站图片,网址是https://www.vmgirls.com/ 分析网页 第一步,打开需要爬取的页面https://www.vmgirls.com/13344.html ...

  8. 今天,你遇到redis线上连接超时了吗?

    一封报警邮件,大量服务节点 redis 响应超时. 又来,好烦. redis 响应变慢,查看日志,发现大量 TimeoutException. 大量TimeoutException,说明当前redis ...

  9. mysqldump 参数--single-transaction

    其实很简单,single-transaction可以让mysqldump 的时候不锁表.但是他有3个前提 innodb的引擎 不能在执行的同时,有其他alter table ,drop table,r ...

  10. vue项目中使用less

    1.安装less less-loader npm i -D less less-loader 2.在 .vue文件中使用lang="less"和@import // home.le ...