Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projeto desafio DIO #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
14 changes: 11 additions & 3 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { log } from 'console'
import { CompanyAccount } from './class/CompanyAccount'
import { PeopleAccount } from './class/PeopleAccount'
import { SpecialAccount } from './class/SpecialAccount'

const peopleAccount: PeopleAccount = new PeopleAccount(1, 'Nath', 10)
console.log(peopleAccount)
peopleAccount.deposit()
peopleAccount.deposit(100)

const companyAccount: CompanyAccount = new CompanyAccount('DIO', 20)
companyAccount.deposit()
console.log(companyAccount)
companyAccount.deposit(100)
companyAccount.getLoan(100)
console.log(companyAccount)

const specialAccount: SpecialAccount = new SpecialAccount('Everton', 30)
specialAccount.deposit(100)
console.log(specialAccount);
9 changes: 7 additions & 2 deletions class/CompanyAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export class CompanyAccount extends DioAccount {
super(name, accountNumber)
}

getLoan = (): void => {
console.log('Voce pegou um empréstimo')
getLoan = (amount: number): void => {
if (this.getStatus()) {
this.balance += amount;
console.log('Voce pegou um empréstimo')
} else{
throw new Error("Não é possível pegar um empréstimo com a conta desativada")
}
}
}
14 changes: 11 additions & 3 deletions class/DioAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ export abstract class DioAccount {
return this.name
}

deposit = (): void => {
getStatus = (): boolean => {
return this.status;
}

deposit = (amount: number): void => {
if(this.validateStatus()){
this.balance += amount;
console.log('Voce depositou')
}
}

withdraw = (): void => {
withdraw = (amount: number): void => {
if (this.balance > amount) {
this.balance -= amount;
}
console.log('Voce sacou')
}

Expand All @@ -39,4 +47,4 @@ export abstract class DioAccount {

throw new Error('Conta inválida')
}
}
}
8 changes: 8 additions & 0 deletions class/SpecialAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DioAccount } from "./DioAccount";

export class SpecialAccount extends DioAccount{

deposit = (amount: number): void => {
this.balance += amount + 10;
}
}