battleship/demo/ship.js

38 lines
632 B
JavaScript
Raw Permalink Normal View History

2022-09-14 09:34:39 +00:00
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 }