diff --git a/.github/.keep b/.github/.keep new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index cab3c08..76507d5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/W3nV4mdD) # Banking management ## Overview diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a8b2f2..d722b73 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -866,4 +866,4 @@ snapshots: why-is-node-running@2.3.0: dependencies: siginfo: 2.0.0 - stackback: 0.0.2 + stackback: 0.0.2 \ No newline at end of file diff --git a/src/__tests__/helpers/TestFactory.ts b/src/__tests__/helpers/TestFactory.ts index ba68f35..a437025 100644 --- a/src/__tests__/helpers/TestFactory.ts +++ b/src/__tests__/helpers/TestFactory.ts @@ -42,7 +42,7 @@ export class TestFactory { }; } - static createBank(options?: { isNegativeAllowed?: boolean }): Bank { + static createBank(options: { isNegativeAllowed: boolean }): Bank { return Bank.create(options); } diff --git a/src/models/bank-account.ts b/src/models/bank-account.ts new file mode 100644 index 0000000..d1ec25a --- /dev/null +++ b/src/models/bank-account.ts @@ -0,0 +1,19 @@ +import { BankAccountId } from "@/types/Common"; + +export default class BankAccount { + id:string + private balance:number + + constructor(initialBalance: number){ + this.balance = initialBalance + this.id = this.generateId(); + } + + private generateId(): BankAccountId { + return Math.random().toString(36).substr(2, 9); + } + + getId(): BankAccountId { + return this.id; + } +} \ No newline at end of file diff --git a/src/models/bank.ts b/src/models/bank.ts new file mode 100644 index 0000000..36cde60 --- /dev/null +++ b/src/models/bank.ts @@ -0,0 +1,28 @@ +import BankAccount from './bank-account'; + +export default class Bank { + constructor() { + let bankId; + } + + static create(options?: { isNegativeAllowed: boolean }): Bank { + return new Bank(); + } + + getId() { + return 1; + } + + createAccount(initialBalance: number): BankAccount { + return new BankAccount(initialBalance); + } + + send( + senderUserId: string, + receiverUserId: string, + amount: number, + bankId?: number + ): void { + // Implementation of the send method + } +} diff --git a/src/models/user.ts b/src/models/user.ts new file mode 100644 index 0000000..a0dbfef --- /dev/null +++ b/src/models/user.ts @@ -0,0 +1,29 @@ +import { UserId, BankAccountId } from '@/types/Common'; + +export default class User { + private id: UserId; + private name: string; + private accountIds: BankAccountId[]; + + constructor(name: string, accountIds: BankAccountId[]) { + this.id = this.generateId(); + this.name = name; + this.accountIds = accountIds; + } + + static create(name: string, accountIds: BankAccountId[]): User { + return new User(name, accountIds); + } + + private generateId(): UserId { + return Math.random().toString(36).substr(2, 9); + } + + getId(): UserId { + return this.id; + } + + getAccountIds(): BankAccountId[] { + return this.accountIds; + } +} \ No newline at end of file diff --git a/src/services/GlobalRegistry.ts b/src/services/GlobalRegistry.ts new file mode 100644 index 0000000..6be4bdf --- /dev/null +++ b/src/services/GlobalRegistry.ts @@ -0,0 +1,3 @@ +export default class GlobalRegistry { + static clear() {} +} diff --git a/src/services/TransactionService.ts b/src/services/TransactionService.ts new file mode 100644 index 0000000..aa3a48c --- /dev/null +++ b/src/services/TransactionService.ts @@ -0,0 +1,3 @@ +export default class TransactionService{ + +} \ No newline at end of file diff --git a/src/types/Common.ts b/src/types/Common.ts new file mode 100644 index 0000000..e79c6a6 --- /dev/null +++ b/src/types/Common.ts @@ -0,0 +1,2 @@ +export type BankAccountId = string; +export type UserId = string; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 12e1b9f..0ff6204 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "baseUrl": "src", // Set the base URL to the src directory "paths": { - "@/*": ["*"] // Optional: Map '@/' to the src directory + "@/*": ["*","src"] // Optional: Map '@/' to the src directory } } } \ No newline at end of file