-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreditCardDemo.java
34 lines (33 loc) · 1.24 KB
/
CreditCardDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Demonstrates the CreditCard class
public class CreditCardDemo
{
public static void main(String[] args)
{
final Money LIMIT = new Money(1000);
final Money FIRST_AMOUNT = new Money(200);
final Money SECOND_AMOUNT = new Money(10.02);
final Money THIRD_AMOUNT = new Money(25);
final Money FOURTH_AMOUNT = new Money(990);
Person owner = new Person("Christie", "Diane",
new Address("237J Harvey Hall", "Menomonie",
"WI", "54751"));
CreditCard visa = new CreditCard(owner, LIMIT);
System.out.println(visa.getPersonals());
System.out.println("Balance: " + visa.getBalance());
System.out.println("Credit Limit: "
+ visa.getCreditLimit());
System.out.println();
System.out.println("Attempt to charge " + FIRST_AMOUNT);
visa.charge(FIRST_AMOUNT);
System.out.println("Balance: " + visa.getBalance());
System.out.println("Attempt to charge " + SECOND_AMOUNT);
visa.charge(SECOND_AMOUNT);
System.out.println("Balance: " + visa.getBalance());
System.out.println("Attempt to pay " + THIRD_AMOUNT);
visa.payment(THIRD_AMOUNT);
System.out.println("Balance: " + visa.getBalance());
System.out.println("Attempt to charge " + FOURTH_AMOUNT);
visa.charge(FOURTH_AMOUNT);
System.out.println("Balance: " + visa.getBalance());
}
}