mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-07-15 05:40:36 -04:00
feat: ship class and test
This commit is contained in:
parent
36bf0c07d6
commit
685020dc94
14 changed files with 9884 additions and 0 deletions
0
battleship/src/components/gameboard.js
Normal file
0
battleship/src/components/gameboard.js
Normal file
16
battleship/src/components/ship.js
Normal file
16
battleship/src/components/ship.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
class Ship {
|
||||
constructor(length) {
|
||||
this.length = length;
|
||||
this.hits = 0;
|
||||
}
|
||||
|
||||
hit() {
|
||||
this.hits += 1
|
||||
}
|
||||
|
||||
isSunk() {
|
||||
return this.hits === this.length
|
||||
}
|
||||
}
|
||||
|
||||
export { Ship }
|
0
battleship/src/index.js
Normal file
0
battleship/src/index.js
Normal file
Loading…
Add table
Add a link
Reference in a new issue