Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .github/.keep
Empty file.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/__tests__/helpers/TestFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class TestFactory {
};
}

static createBank(options?: { isNegativeAllowed?: boolean }): Bank {
static createBank(options: { isNegativeAllowed: boolean }): Bank {
return Bank.create(options);
}

Expand Down
19 changes: 19 additions & 0 deletions src/models/bank-account.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
28 changes: 28 additions & 0 deletions src/models/bank.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
29 changes: 29 additions & 0 deletions src/models/user.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 3 additions & 0 deletions src/services/GlobalRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class GlobalRegistry {
static clear() {}
}
3 changes: 3 additions & 0 deletions src/services/TransactionService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class TransactionService{

}
2 changes: 2 additions & 0 deletions src/types/Common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type BankAccountId = string;
export type UserId = string;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Loading