-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercicio1.js
More file actions
32 lines (23 loc) · 836 Bytes
/
Exercicio1.js
File metadata and controls
32 lines (23 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var Veiculo = function(nome, cor, modelo) {
var cor = cor;
var nome = nome;
var modelo = modelo;
this.getCor = () => cor;
this.getNome = () => nome;
this.getModelo = () => modelo;
}
var CaminhaoCegonha = function(nome, cor, modelo) {
Veiculo.call(this, nome, cor, modelo);
this.listaVeiculos = [];
this.getVeiculos = () => listaVeiculos.map( (v) => `${v.getNome()} ${v.getCor()} ${v.getModelo()}` ).join(', ');
this.addVeiculo = (veiculo) => listaVeiculos.push(veiculo);
this.removeVeiculo = () => listaVeiculos.pop();
}
var a = new Veiculo('Moto', 'branca', 2018);
var b = new Veiculo('Carro', 'preto', 2016);
var c = new Veiculo('Van', 'azul', 2007);
var cegonha = new CaminhaoCegonha('Caminhão Cegonha', 'verde', 2005);
cegonha.addVeiculo(a);
cegonha.addVeiculo(b);
cegonha.addVeiculo(c);
cegonha.getVeiculos();