Browse Source

Merge remote-tracking branch 'origin/main'

main
Justin Senn 2 years ago
parent
commit
3622962796
  1. 6
      src/main/java/BattleShip/AIGridGUI.java
  2. 26
      src/main/java/BattleShip/BSButton.java
  3. 4
      src/main/java/BattleShip/BShip.java
  4. 23
      src/main/java/BattleShip/Direction.java
  5. 35
      src/main/java/BattleShip/Ship.java

6
src/main/java/BattleShip/AIGridGUI.java

@ -0,0 +1,6 @@
package BattleShip;
import javax.swing.*;
public class AIGridGUI extends JPanel {
}

26
src/main/java/BattleShip/BSButton.java

@ -0,0 +1,26 @@
package BattleShip;
import javax.swing.*;
public class BSButton extends JButton {
int gridLocation;
Ship cellContents = null;
public void setGridLocation(int l) {
gridLocation = l;
}
public int getGridLocation() {
return gridLocation;
}
public void setCellContents(Ship s) {
cellContents = s;
}
public Ship getCellContents() {
return cellContents;
}
}

4
src/main/java/BattleShip/BShip.java

@ -0,0 +1,4 @@
package BattleShip;
public class BShip {
}

23
src/main/java/BattleShip/Direction.java

@ -0,0 +1,23 @@
package BattleShip;
class Direction {
int countHits, cellLocation;
public void setCount(int a) {
countHits = a;
}
public int getCount() {
return countHits;
}
public void setCell(int b) {
cellLocation = b;
}
public int getCell() {
return cellLocation;
}
}

35
src/main/java/BattleShip/Ship.java

@ -0,0 +1,35 @@
package BattleShip;
public class Ship {
String name;
int length;
public int numOfHits = 0;
boolean kill = false;
public Ship(int l, String n) {
length = l;
name = n;
}
public String getName() {
return name;
}
public int getLength() {
return length;
}
public boolean isKilled() {
return kill;
}
public boolean counter() {
//Count hits until number of hits equals ship length, then mark as killed.
numOfHits++;
if(numOfHits == length) {
kill = true;
}
return kill;
}
}
Loading…
Cancel
Save