⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 withdraw.java

📁 Java 入门书的源码
💻 JAVA
字号:
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.

/*  Uses the withdraw operation of
 *  BankAccount and its subclasses
 *  to illustrate polymorphism
 */

import iopack.Io;
public class Withdraw {
  public static void main(String [] args) {
    BankAccount b1 = new CheckingAccount(1500.00,.50);
    BankAccount b2 = new SavingsAccount(500.00, 4.0);
    b1.deposit(400.00);
    b1.withdraw(50.00);
    System.out.print("The balance of the BankAccount to which b1 refers is ");  
    Io.println$(b1.getBalance());
    b2.withdraw(50.00);
    System.out.print("The balance of the BankAccount to which b2 refers is ");  
    Io.println$(b2.getBalance());
    b2 = b1;
    b2.withdraw(50.00); 
    System.out.print("The balance of the BankAccount to which b2 refers is ");  
    Io.println$(b2.getBalance());
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -