JAVA面对对象---构造器,private,this,封装实际应用题 银行存钱取款问题

(1) 创建一个 Customer ,名字叫 Jane Smith, 他有一个账号为 1000,余额为 2000 元,
年利率为 1.23% 的账户。
(2) 对 Jane Smith 操作。
存入 100 元,再取出 960 元。再取出 2000 元。
打印出 Jane Smith 的基本信息

*成功存入 :100.0
成功取出:960.0
余额不足,取款失败
Customer [Smith, Jane] has a account: id is 1000, annualInterestRate is 1.23%, balance is
1140.0

先创建class文件Account.java

//Account账单类
public class Account{
   
	private int id;//账户
	private double balance;//余额
	private double annualinterestRate;//年利率
	
	public Account(int id,double balance,double annualinterestRate) {
   
		this.balance=balance;
		this.id=id;
		this.annualinterestRate=annualinterestRate;
	}

	public int getId() {
   
		return id;
	}

	public void setId(int id) {
   
		this.id = id;
	}

	public double getBalance() {
   
		
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值