1+ using Classes_M2 ;
2+
3+ // Step 1: Create BankCustomer objects
4+ Console . WriteLine ( "Creating BankCustomer objects..." ) ;
5+ string firstName = "Tim" ;
6+ string lastName = "Shao" ;
7+
8+ BankCustomer customer1 = new BankCustomer ( firstName , lastName ) ;
9+
10+ firstName = "Lisa" ;
11+ BankCustomer customer2 = new BankCustomer ( firstName , lastName ) ;
12+
13+ firstName = "Sandy" ;
14+ lastName = "Zoeng" ;
15+ BankCustomer customer3 = new BankCustomer ( firstName , lastName ) ;
16+
17+ Console . WriteLine ( $ "BankCustomer 1: { customer1 . FirstName } { customer1 . LastName } { customer1 . customerId } ") ;
18+ Console . WriteLine ( $ "BankCustomer 2: { customer2 . FirstName } { customer2 . LastName } { customer2 . customerId } ") ;
19+ Console . WriteLine ( $ "BankCustomer 3: { customer3 . FirstName } { customer3 . LastName } { customer3 . customerId } ") ;
20+
21+ // Step 2: Create BankAccount objects for customers
22+ Console . WriteLine ( "\n Creating BankAccount objects for customers..." ) ;
23+ BankAccount account1 = new BankAccount ( customer1 . customerId ) ;
24+ BankAccount account2 = new BankAccount ( customer2 . customerId , 1500 , "Checking" ) ;
25+ BankAccount account3 = new BankAccount ( customer3 . customerId , 2500 , "Checking" ) ;
26+
27+ Console . WriteLine ( $ "Account 1: Account # { account1 . AccountNumber } , type { account1 . AccountType } , balance { account1 . Balance } , rate { BankAccount . interestRate } , customer ID { account1 . CustomerId } ") ;
28+ Console . WriteLine ( $ "Account 2: Account # { account2 . AccountNumber } , type { account2 . AccountType } , balance { account2 . Balance } , rate { BankAccount . interestRate } , customer ID { account2 . CustomerId } ") ;
29+ Console . WriteLine ( $ "Account 3: Account # { account3 . AccountNumber } , type { account3 . AccountType } , balance { account3 . Balance } , rate { BankAccount . interestRate } , customer ID { account3 . CustomerId } ") ;
30+
31+ // Step 3: Demonstrate the use of BankCustomer properties
32+ Console . WriteLine ( "\n Updating BankCustomer 1's name..." ) ;
33+ customer1 . FirstName = "Thomas" ;
34+ customer1 . LastName = "Margand" ;
35+ Console . WriteLine ( $ "Updated BankCustomer 1: { customer1 . FirstName } { customer1 . LastName } { customer1 . customerId } ") ;
36+
37+ // Step 4: Demonstrate the use of BankAccount methods
38+ Console . WriteLine ( "\n Demonstrating BankAccount methods..." ) ;
39+
40+ // Deposit
41+ Console . WriteLine ( "Depositing 500 into Account 1..." ) ;
42+ account1 . Deposit ( 500 ) ;
43+ Console . WriteLine ( $ "Account 1 after deposit: Balance = { account1 . Balance } ") ;
44+
45+ // Withdraw
46+ Console . WriteLine ( "Withdrawing 200 from Account 2..." ) ;
47+ bool withdrawSuccess = account2 . Withdraw ( 200 ) ;
48+ Console . WriteLine ( $ "Account 2 after withdrawal: Balance = { account2 . Balance } , Withdrawal successful: { withdrawSuccess } ") ;
49+
50+ // Transfer
51+ Console . WriteLine ( "Transferring 300 from Account 3 to Account 1..." ) ;
52+ bool transferSuccess = account3 . Transfer ( account1 , 300 ) ;
53+ Console . WriteLine ( $ "Account 3 after transfer: Balance = { account3 . Balance } , Transfer successful: { transferSuccess } ") ;
54+ Console . WriteLine ( $ "Account 1 after receiving transfer: Balance = { account1 . Balance } ") ;
55+
56+ // Apply interest
57+ Console . WriteLine ( "Applying interest to Account 1..." ) ;
58+ account1 . ApplyInterest ( ) ;
59+ Console . WriteLine ( $ "Account 1 after applying interest: Balance = { account1 . Balance } ") ;
60+
61+ // Step 5: Demonstrate the use of extension methods
62+ Console . WriteLine ( "\n Demonstrating extension methods..." ) ;
63+ Console . WriteLine ( customer1 . GreetCustomer ( ) ) ;
64+ Console . WriteLine ( $ "Is customer1 ID valid? { customer1 . IsValidCustomerId ( ) } ") ;
65+ Console . WriteLine ( $ "Can account2 withdraw 2000? { account2 . CanWithdraw ( 2000 ) } ") ;
66+ Console . WriteLine ( $ "Is account3 overdrawn? { account3 . IsOverdrawn ( ) } ") ;
67+
68+ // Step 6: Display customer and account information
69+ Console . WriteLine ( "\n Displaying customer and account information..." ) ;
70+ Console . WriteLine ( customer1 . DisplayCustomerInfo ( ) ) ;
71+ Console . WriteLine ( account1 . DisplayAccountInfo ( ) ) ;
0 commit comments