Package exercises.manualTests

Source Code of exercises.manualTests.TestCreditCard

package exercises.manualTests;

import exercises.models.CreditCard;

public class TestCreditCard {
 
  public void Run() {
   
    CreditCard[] wallet = {
        new CreditCard("2534 8576 8125 7593", "Fictional Guy", "CIBC", 0.0, 7000, 0.125),
        new CreditCard("6396 3452 0876 1209", "Fictional Girl", "Royal Bank", 0.0, 10000, 0.1345),
        new CreditCard("9752 9723 8365 3421", "Fictional Alien", "Toronto Dominion", 0.0, 6000, 0.1524)
    };
   
    for( int i = 0; i < 16; i++ ) {
      charge( wallet[ 0 ], (double)i );
      charge( wallet[ 1 ], 2.0 * i );
      charge( wallet[ 2 ], (double)65 * i );
    }
   
    System.out.println();
   
    for( CreditCard card : wallet ) {
     
      CreditCard.printCard( card );
     
      System.out.println( "*********************" );
      while( card.getBalance() > 100.0 ) {
        card.makePayment( 100.00 );
        System.out.println( "Payment made -> New Balance = " + card.getBalance() );
      }
      System.out.println( "*********************\n" );
     
    }
   
  }
 
  private void charge( CreditCard card, double amt ) {
   
    if( card.chargeIt( amt ) ) return;
   
    System.out.println( "Sorry Card " + card.getNumber() + " has insufficient funds." );
     
  }
 
  public static void main( String[] args ) {
   
    new TestCreditCard().Run();
   
  }
 
}
TOP

Related Classes of exercises.manualTests.TestCreditCard

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.