38 lines
632 B
JavaScript
38 lines
632 B
JavaScript
class Ship {
|
|
constructor(name, length) {
|
|
this.name = name
|
|
this.length = length
|
|
}
|
|
}
|
|
|
|
class Carrier extends Ship {
|
|
constructor() {
|
|
super('Carrier', 5)
|
|
}
|
|
}
|
|
|
|
class Battleship extends Ship {
|
|
constructor() {
|
|
super('Battleship', 4)
|
|
}
|
|
}
|
|
|
|
class Destroyer extends Ship {
|
|
constructor() {
|
|
super('Destroyer', 3)
|
|
}
|
|
}
|
|
|
|
class Submarine extends Ship {
|
|
constructor() {
|
|
super('Submarine', 3)
|
|
}
|
|
}
|
|
class Patrolboat extends Ship {
|
|
constructor() {
|
|
super('Patrolboat', 2)
|
|
}
|
|
}
|
|
|
|
module.exports = { Carrier, Battleship, Destroyer, Submarine, Patrolboat }
|