Untitled

 avatar
unknown
typescript
2 years ago
1.6 kB
6
Indexable
// Instantiate the bank
let bank = new Bank();
bank.name = "OpenAI Bank";

// Create some customers
let customer1 = new Customer();
customer1.name = "Alice";
customer1.address = "123 Main St";
customer1.phoneNumber = "555-555-5555";
customer1.accounts = [];

let customer2 = new Customer();
customer2.name = "Bob";
customer2.address = "456 Second Ave";
customer2.phoneNumber = "555-555-5556";
customer2.accounts = [];

// Add customers to the bank
bank.customers.push(customer1);
bank.customers.push(customer2);

// Create accounts for the customers
let account1 = bank.createAccount(customer1);
account1.accountNumber = "001";
account1.balance = 1000;

let account2 = bank.createAccount(customer2);
account2.accountNumber = "002";
account2.balance = 2000;

// Create credit cards for the accounts
let creditCard1 = bank.createCreditCard(account1);
creditCard1.cardNumber = "1234567891234567";
creditCard1.expirationDate = new Date(2025, 11);
creditCard1.balance = 500;

let creditCard2 = bank.createCreditCard(account2);
creditCard2.cardNumber = "2345678912345678";
creditCard2.expirationDate = new Date(2025, 11);
creditCard2.balance = 1000;

// Print out account balances
console.log(`Account balance for ${customer1.name}: ${account1.balance}`);
console.log(`Account balance for ${customer2.name}: ${account2.balance}`);

// Let's make a transfer
console.log("Transferring $500 from Alice to Bob");
account1.transfer(500, account2);

// Print out account balances after the transfer
console.log(`Account balance for ${customer1.name}: ${account1.balance}`);
console.log(`Account balance for ${customer2.name}: ${account2.balance}`);
Editor is loading...