https://github.com/tiagocbarbosa/javascript-oop
https://github.com/tiagocbarbosa/javascript-oop
javascript-es6 oop poo
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tiagocbarbosa/javascript-oop
- Owner: tiagocbarbosa
- Created: 2020-09-20T15:51:32.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-11T12:58:37.000Z (over 4 years ago)
- Last Synced: 2025-01-19T23:23:41.679Z (5 months ago)
- Topics: javascript-es6, oop, poo
- Language: JavaScript
- Homepage:
- Size: 40 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# javascript-oop
This is my `javascript` project using some OOP concepts.## About
It is highly recommended to start looking at the "index.js" file, there I explain some aspects of my project.Check below a list of OOP concepts that you will find in this project.
### Class
In "Client\Client.js":
```js
class Client {
// ...
}
```### Encapsulation
Private attribute in "Employee\Employee.js":
```js
constructor(name, salary, cpf) {
this._name = name
// ...
}
```### Abstraction
Abstract method in "Account\Account.js":
```js
withdraw(value) {
throw new Error('Abstract methods must be overwritten')
}
```
Abstract class in "Account\Account.js":
```js
constructor(initialBalance, client, agency) {
if(this.constructor == Account) {
throw new Error('You cannot initialize an Abstract class of the type Account')
}
// ...
}
```### Inheritance
In "Account\SavingAccount.js":
```js
class SavingAccount extends Account {
// ...
}
```### Polymorphism
In "Account\CheckingAccount.js":
```js
withdraw(value) {
const tax = 1.1
return this._withdraw(value, tax)
}
```
In "Account\SalaryAccount.js":
```js
withdraw(value) {
const tax = 1.01
return this._withdraw(value, tax)
}
```### Interface
In "AuthenticationSystem\AuthenticationSystem.js":
```js
static isAuthenticable(authenticable) {
return 'authenticate' in authenticable
&& authenticable.authenticate instanceof Function
}
```------
And that's pretty much it, hope you liked it! Thanks :)