//package Chap4;
import java.io.*;

// CSC108 Chapter 4, Question 18
// Name:  Iam Me         Student ID: 555555555
// Tutor: Andria Hunter  Prof: Ken Jackson
//
// Program Description: This program uses the Bank_Account class
//     to create two bank account objects.  It then uses the 
//     debit, credit, and get_balance methods on these objects.
//     This program uses two classes: one for the bank account
//     and its operations (Bank_Account), and one that contains
//     the main method (CIBC_Bank).

// The Bank_Account class contains a variable that stores the
// current balance, and methods that can be used to deposit,
// withdraw, and display the current balance.

class Bank_Account {

   // Stores the current balance of the Bank_Account object.
   private double balance;

   // Constructor to initialize the account balance.
   public Bank_Account (double start_balance) {
      balance = start_balance;
   }

   // Method to decrease the account balance by the amount passed.
   public void debit (double amount) {
      balance = balance - amount;
   }

   // Method to increase the account balance by the amount passed.
   public void credit (double amount) {
      balance = balance + amount;
   }

   // Method that returns the current balance of the account.
   public double get_balance () {
      return balance;
   }
}

// The CIBC_Bank class contains one main method where program execution
// starts.  The two bank accounts are created in this method.

class CIBC_Bank {

   // Main method to create two bank account (Bank_Account) objects,
   // and to perform various methods on these objects.

   public static void main (String[] args) throws IOException {

      //---------
      // Create account 1 and use methods on this account.

      Bank_Account account_one = new Bank_Account (10.0);
      account_one.credit(5.0);
      account_one.debit(3.0);
      System.out.println ("Account 1 final balance: "+
                            account_one.get_balance());
      
      //---------
      // Create account 2 and use methods on this account.

      Bank_Account account_two = new Bank_Account (150.0);
      account_two.credit(40.0);
      account_two.debit(100.0);
      System.out.println ("Account 2 final balance: "+
                            account_two.get_balance());
   }
}

