/** 
 * Exercises equals()
 *
 * @author Hyrum D. Carroll
 * @version 0.1 (10/12/2020)
 */
public class BankAccounts03{
    final public static double INTEREST_RATE = 0.01;  // 1%

    public static void main( String[] args ){
        CheckingAccount checking = new CheckingAccount( 100.0, "checking123" );
        SavingsAccount savings = new SavingsAccount( 1000.0, "savings124", INTEREST_RATE );

        CheckingAccount checkingCopy = new CheckingAccount( 100.0, "checking123" );
        SavingsAccount savingsCopy = new SavingsAccount( 1000.0, "savings124", INTEREST_RATE );

        boolean passed = true;
        String msg = "";

        if( checking.equals( checkingCopy ) == false ){
            passed = false;
            msg += "Failed checking.equals( checkingCopy ) == false;\n";
            msg += "\tThe following objects are equal:\n" + checking + "\n" + checkingCopy + "\n";
        }

        if( savings.equals( savingsCopy ) == false ){
            passed = false;
            msg += "Failed savings.equals( savingsCopy ) == false;\n";
            msg += "\tThe following objects are equal:\n" + savings + "\n" + savingsCopy + "\n";
        }

        int electricBillCheckNum = 2123;
        double electricBill = 60.34;
        double futureCar = 200.0;

        checking.processCheck( electricBillCheckNum, electricBill );

        savings.deposit( futureCar );
        savings.applyInterest( );

        if( checking.equals( checkingCopy ) == true ){
            passed = false;
            msg += "Failed checking.equals( checkingCopy ) == true;\n";
            msg += "\tThe following objects are NOT equal:\n" + checking + "\n" + checkingCopy + "\n";
        }

        if( savings.equals( savingsCopy ) == true ){
            passed = false;
            msg += "Failed savings.equals( savingsCopy ) == true;\n";
            msg += "\tThe following objects are NOT equal:\n" + savings + "\n" + savingsCopy + "\n";
        }

        if( passed == false ){
            System.err.print( msg );
        }
    }
}