admin管理员组

文章数量:1648000

续标题:创建支票账户checking account和储蓄账户saving account两个子类。支票账户有一个透支限定额,但储蓄账户不能透支

  • 题目(续)
  • 题目中提到的编程练习题9.7:以下代码直接利用即可
  • Test03_checking_account:支票账户
  • Test03_saving_account
  • Test03:测试程序(创建三个对象并调用toString方法)
  • 总UML图

题目(续)

画出这些类的UML图并实现这些类。编写一个测试程序,创建Account、SavingsAccount和CheckingAccount的对象,然后调用它们的toString()方法

题目中提到的编程练习题9.7:以下代码直接利用即可

省流助手:四个私有数据域 + 无参有参构造方法 + id balance annualInterestRate三个数据域的setter和getter方法 + dateCreated的访问器方法 + getMonthlyInterestRate方法 + getMonthlyInterest方法 + withDraw方法 + deposit方法

import java.util.Date;

public class Test2_Account {
   
    // 四个私有数据域
    private int id = 0;
    private double balance = 0.0;
    private double annualInterestRate = 0.0;
    private Date dateCreated;

    // 无参构造方法
    public Test2_Account(){
   
    }
    // 有参构造方法
    public Test2_Account(int id, double balance){
   
        this.id = id;
        this.balance = balance;
    }
    // id balance annualInterestRate的setter和getter
    public int getId() {
   
        return id;
    }
    public 

本文标签: 黑皮账户年利率子类练习题