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

desafio-diobank #13

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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 26 additions & 6 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
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()
const companyAccount: CompanyAccount = new CompanyAccount('DIO', 20)
companyAccount.deposit()
console.log(companyAccount)

// Alterar valor do saldo conforme depósito
const peopleAccount : PeopleAccount = new PeopleAccount(1, "Thalita Costa", 1234)

peopleAccount.deposit(50)
peopleAccount.deposit(100)


// Apenas contas ativas e com saldo maior que o solicitado no saque podem realizar saques

peopleAccount.withdraw(20)
peopleAccount.withdraw(500)

// Acrescente o valor do empréstimo ao saldo atual

const companyAccount : CompanyAccount = new CompanyAccount("Thalita", 1235)

companyAccount.deposit(500)
companyAccount.getLoan(1200)

// Esta conta terá um método de depósito, que acresce 10 a mais ao valor informado para depósito

const specialAccount: SpecialAccount = new SpecialAccount("Thalita", 1236)
specialAccount.getBalance()
specialAccount.deposit(200)
10 changes: 8 additions & 2 deletions class/CompanyAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ export class CompanyAccount extends DioAccount {
super(name, accountNumber)
}

getLoan = (): void => {
console.log('Voce pegou um empréstimo')
getLoan = (loan: number): void => {
if(this.validateStatus()){
let balance = this.getBalance()
balance += loan
console.log("Você realizou um empréstimo de R$ " + loan + " e agora seu saldo atual é de R$ " + balance)
} else {
console.log("Sua conta está inativa.")
}
}
}
32 changes: 18 additions & 14 deletions class/DioAccount.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
export abstract class DioAccount {
private name: string
private readonly name: string
private readonly accountNumber: number
balance: number = 0
private balance: number = 0
private status: boolean = true

constructor(name: string, accountNumber: number){
this.name = name
this.accountNumber = accountNumber
}

setName = (name: string): void => {
this.name = name
console.log('Nome alterado com sucesso!')
}

getName = (): string => {
return this.name
}

deposit = (): void => {
deposit = (deposit: number): void => {
if(this.validateStatus()){
console.log('Voce depositou')
this.balance += deposit
console.log("Seu saldo atual é de " + this.balance)
}
}

withdraw = (): void => {
console.log('Voce sacou')
withdraw = (withdraw: number): void => {
if(this.validateStatus() && this.balance > withdraw){
this.balance -= withdraw
console.log("Você sacou o valor de R$ " + withdraw + "\nAgora seu saldo é de R$ " + this.balance)
} else if (!this.validateStatus()) {
console.log("Sua conta está inativa.")
} else {
console.log("O valor de saque deve ser menor que o valor atual de saldo em sua conta")
}
}

getBalance = (): void => {
console.log(this.balance)
getBalance = (): number => {
return this.balance
}

private validateStatus = (): boolean => {
validateStatus = (): boolean => {
if (this.status) {
return this.status
}

throw new Error('Conta inválida')
}
}

2 changes: 1 addition & 1 deletion class/PeopleAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DioAccount } from "./DioAccount"

export class PeopleAccount extends DioAccount {
doc_id: number
private doc_id: number

constructor(doc_id: number, name: string, accountNumber: number){
super(name, accountNumber)
Expand Down
14 changes: 14 additions & 0 deletions class/SpecialAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DioAccount } from "./DioAccount"

export class SpecialAccount extends DioAccount {

constructor(name: string, accountNumber: number){
super(name, accountNumber)
}

deposit = (deposit: number): void => {
let balance = this.getBalance()
balance += deposit + 10
console.log("Você depositou R$ " + deposit + " em sua conta especial e agora seu saldo é de R$ " + balance)
}
}
12 changes: 12 additions & 0 deletions node_modules/.bin/acorn

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

17 changes: 17 additions & 0 deletions node_modules/.bin/acorn.cmd

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

28 changes: 28 additions & 0 deletions node_modules/.bin/acorn.ps1

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

12 changes: 12 additions & 0 deletions node_modules/.bin/mkdirp

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

17 changes: 17 additions & 0 deletions node_modules/.bin/mkdirp.cmd

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

28 changes: 28 additions & 0 deletions node_modules/.bin/mkdirp.ps1

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

12 changes: 12 additions & 0 deletions node_modules/.bin/resolve

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

17 changes: 17 additions & 0 deletions node_modules/.bin/resolve.cmd

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

28 changes: 28 additions & 0 deletions node_modules/.bin/resolve.ps1

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

12 changes: 12 additions & 0 deletions node_modules/.bin/rimraf

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

17 changes: 17 additions & 0 deletions node_modules/.bin/rimraf.cmd

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

28 changes: 28 additions & 0 deletions node_modules/.bin/rimraf.ps1

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

12 changes: 12 additions & 0 deletions node_modules/.bin/tree-kill

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

Loading