Commit d4115f0d authored by BRADLEY VERNON's avatar BRADLEY VERNON

First commit.

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
!SESSION 2019-04-28 17:01:14.920 -----------------------------------------------
eclipse.buildId=4.10.0.I20181206-0815
java.version=1.8.0_202
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY org.eclipse.egit.ui 2 0 2019-04-28 17:01:50.221
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Darth Vernon'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
content_assist_proposals_background=255,255,255
content_assist_proposals_foreground=0,0,0
eclipse.preferences.version=1
org.eclipse.jdt.internal.ui.navigator.layout=2
org.eclipse.jdt.internal.ui.navigator.librariesnode=true
org.eclipse.jdt.ui.formatterprofiles.version=15
org.eclipse.jdt.ui.text.code_templates_migrated=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
spelling_locale=en_GB
spelling_locale_initialized=true
useAnnotationsPrefPage=true
useQuickDiffPrefPage=true
eclipse.preferences.version=1
org.eclipse.jsch.core.hasChangedDefaultWin32SshHome=true
eclipse.preferences.version=1
org.eclipse.m2e.discovery.pref.projects=
eclipse.preferences.version=1
org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true
eclipse.preferences.version=1
migrated.task.repositories.secure.store=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true
org.eclipse.mylyn.tasks.ui.welcome.message=true
PROBLEMS_FILTERS_MIGRATE=true
eclipse.preferences.version=1
platformState=1552938863790
quickStart=false
tipsAndTricks=true
//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false
PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery;
eclipse.preferences.version=1
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<typeInfoHistroy/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<qualifiedTypeNameHistroy/>
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart">
<item value="2" key="layout"/>
<item value="true" key="group_libraries"/>
<item value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#x0D;&#x0A;&lt;packageExplorer group_libraries=&quot;1&quot; layout=&quot;2&quot; linkWithEditor=&quot;0&quot; rootMode=&quot;1&quot; workingSetName=&quot;Aggregate for window 1556467303927&quot;&gt;&#x0D;&#x0A;&lt;customFilters userDefinedPatternsEnabled=&quot;false&quot;&gt;&#x0D;&#x0A;&lt;xmlDefinedFilters&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.StaticsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.buildship.ui.packageexplorer.filter.gradle.buildfolder&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.mylyn.java.ui.MembersFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonSharedProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.EmptyInnerPackageFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.m2e.MavenModuleFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.buildship.ui.packageexplorer.filter.gradle.subProject&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ClosedProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.EmptyLibraryContainerFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.PackageDeclarationFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.pde.ui.BinaryProjectFilter1&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.LocalTypesFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.pde.ui.ExternalPluginLibrariesFilter1&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.FieldsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonJavaProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer_patternFilterId_.*&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.SyntheticMembersFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ContainedLibraryFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.HideInnerClassFilesFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.DeprecatedMembersFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ImportDeclarationFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonJavaElementFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.LibraryFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.CuAndClassFileFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.EmptyPackageFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonPublicFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;/xmlDefinedFilters&gt;&#x0D;&#x0A;&lt;/customFilters&gt;&#x0D;&#x0A;&lt;/packageExplorer&gt;" key="memento"/>
<item value="1" key="rootMode"/>
<item value="false" key="linkWithEditor"/>
</section>
</section>
2019-04-28 17:01:48,731 [Worker-3: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>OFF</level> <!-- change to DEBUG to mimic '-consolelog' behaviour -->
</filter>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${org.eclipse.m2e.log.dir}/0.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${org.eclipse.m2e.log.dir}/%i.log</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>100MB</MaxFileSize>
</triggeringPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<appender name="EclipseLog" class="org.eclipse.m2e.logback.appender.EclipseLogAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<appender name="MavenConsoleLog" class="org.eclipse.m2e.logback.appender.MavenConsoleAppender">
</appender>
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
<appender-ref ref="EclipseLog" />
<appender-ref ref="MavenConsoleLog" />
</root>
<logger name="com.ning.http.client" level="INFO" />
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<setup:Workspace
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:setup="http://www.eclipse.org/oomph/setup/1.0"
name="workspace"/>
#Cached timestamps
#Sun Apr 28 17:03:20 BST 2019
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
</section>
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="ExternalProjectImportWizard">
<item value="false" key="WizardProjectsImportPage.STORE_NESTED_PROJECTS"/>
<item value="false" key="WizardProjectsImportPage.STORE_COPY_PROJECT_ID"/>
<item value="false" key="WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"/>
<list key="WizardProjectsImportPage.STORE_DIRECTORIES">
<item value="D:\Prog2Ass"/>
</list>
<list key="WizardProjectsImportPage.STORE_ARCHIVES">
<item value=""/>
</list>
</section>
</section>
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<item value="1024" key="introLaunchBar.location"/>
</section>
<?xml version="1.0" encoding="UTF-8"?>
<state reopen="true"/>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="org.eclipse.ui.internal.QuickAccess">
<item value="-1" key="dialogHeight"/>
<item value="-1" key="dialogWidth"/>
<list key="textEntries">
</list>
<list key="orderedElements">
</list>
<list key="orderedProviders">
</list>
<list key="textArray">
</list>
</section>
<section name="ImportExportAction">
</section>
</section>
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1556467301561_0" label="Java Main Sources" name="Java Main Sources"/>
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1556467301724_1" label="Java Test Sources" name="Java Test Sources"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1556467303927_2" label="Window Working Set" name="Aggregate for window 1556467303927"/>
</workingSetManager>
\ No newline at end of file
#Sun Apr 28 17:01:35 BST 2019
org.eclipse.core.runtime=2
org.eclipse.platform=4.10.0.v20181206-0815
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.Pane?>
<Pane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="749.0" prefWidth="1054.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="BSMain">
<children>
<Pane accessibleRole="COMBO_BOX" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="749.0" prefWidth="1054.0">
<children>
<ChoiceBox fx:id="DPx" layoutX="41.0" layoutY="679.0" prefHeight="28.0" prefWidth="184.0" />
<ChoiceBox fx:id="DPy" layoutX="225.0" layoutY="679.0" prefHeight="28.0" prefWidth="184.0" />
<Button fx:id="place" layoutX="225.0" layoutY="707.0" mnemonicParsing="false" onAction="#placeAction" prefHeight="28.0" prefWidth="184.0" text="*PLACE A SHIP*" textAlignment="CENTER" />
<ChoiceBox fx:id="shipSelection" layoutX="41.0" layoutY="707.0" prefHeight="28.0" prefWidth="184.0" />
<Label fx:id="label" alignment="CENTER" contentDisplay="CENTER" layoutX="409.0" layoutY="679.0" prefHeight="28.0" prefWidth="184.0" text="Stage : Place your Ships" textAlignment="JUSTIFY" wrapText="true" />
<Button fx:id="fire" layoutX="409.0" layoutY="706.0" mnemonicParsing="false" onAction="#fireAction" prefHeight="28.0" prefWidth="184.0" text="*FIRE*" />
</children>
</Pane>
</children>
</Pane>
import java.util.ArrayList;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class BSMain extends Application{
@FXML public ChoiceBox<String> DPx;
@FXML public ChoiceBox<String> DPy;
@FXML public ChoiceBox<String> shipSelection;
@FXML private Button place;
@FXML private Button fire;
@FXML private Label label;
static ObservableList<String> numbrz = FXCollections.observableArrayList("0","1","2","3","4","5","6","7","8","9");
static ObservableList<String> ltrz = FXCollections.observableArrayList("A","B","C","D","E","F","G","H","I","J");
static ObservableList<String> ships= FXCollections.observableArrayList("Aircraft", "BattleShip","BattleShip Two", "Destroyer One" , "Destroyer Two", "Patrol Boat One" ,
"Patrol Boat Two" , "Patrol Boat Three");
static String x;
static String y;
static String ship;
static Grid playerG = new Grid();
static Grid computerG = new Grid();
static ShipClass playerS = new ShipClass();
static ShipClass computerS = new ShipClass();
@Override
public void start(Stage arg0) throws Exception {
// TODO Auto-generated method stub
Parent root = FXMLLoader.load(getClass().getResource("/BSGUI.fxml"));
//System.out.println(DPx);
Scene scene = new Scene(root, 300, 275);
scene.setRoot(root);
arg0.setTitle("Battleships");
arg0.setScene(scene);
arg0.show();
}
@FXML
public void initialize(){
DPx.getItems().addAll(numbrz);
DPy.getItems().addAll(ltrz);
shipSelection.getItems().addAll(ships);
DPx.getSelectionModel().selectedItemProperty().addListener((ObservableValue, oldValue, newValue) -> {
x=(newValue.toString());
});
DPy.getSelectionModel().selectedItemProperty().addListener((ObservableValue, oldValue, newValue) -> {
y=(newValue.toString());
});
shipSelection.getSelectionModel().selectedItemProperty().addListener((ObservableValue, oldValue, newValue) -> {
ship=(newValue.toString());
});
}
@FXML
void placeAction(ActionEvent event) {
playerS.ShipPlacer(ship, x, y);
if (!playerG.MoveValidCheck(playerG, playerS.moves)){
label.setText("Cordinates are taken. not added to grid");
}
}
@FXML
void fireAction(ActionEvent event) {
// disable during placing stage
// enable once all ships are placed
// notify user in changing of stages
String HmnMove = x + y;
String CmptrMove = (String) ComputerInput.CoOrdRandomiser().get(0)
+ (String) ComputerInput.CoOrdRandomiser().get(1);
BattleClass.fire(computerS, HmnMove);
BattleClass.fire(playerS, CmptrMove);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
playerG.CoOrdGen(playerG);
computerG.CoOrdGen(computerG);
ComputerInput.cmptrMoveGen();
launch(args);
}
}
public class BattleClass {
public static void fire (ShipClass opponent, String Cordinates) {
// loop through shipsHealth array and
// use .contains to see if any ships contain the fired upon coordinates
// then use Grid.sunk() to check if the the entire ship has gone.
}
}
import java.util.ArrayList;
import java.util.Random;
public class ComputerInput {
public static ArrayList CoOrdRandomiser() {
ArrayList coOrd = new ArrayList();
Random rand = new Random();
int indexX = rand.nextInt(10);
int indexY = rand.nextInt(10);
String x = Grid.xCord[indexX];
coOrd.add(x);
String y = Grid.yCord[indexY];
coOrd.add(y);
return coOrd;
}
public static void cmptrMoveGen() {
for (int i = 0 ; i < BSMain.ships.size() ; i ++) {
if (BSMain.computerG.MoveValidCheck(BSMain.computerG, BSMain.computerS.moves) ) {
String x = (String) CoOrdRandomiser().get(0);
String y = (String) CoOrdRandomiser().get(1);
String coOrd = x + y ;
BSMain.computerS.ShipPlacer(BSMain.ships.get(i),x,y);
}
else {
i --;
}
}
}
}
import java.util.ArrayList;
public class Grid {
ArrayList Avblcords = new ArrayList();
static ArrayList xCordL = new ArrayList();
static ArrayList yCordL = new ArrayList();
static String xCord[] = {"0","1","2","3","4","5","6","7","8","9"};
static String yCord[] = {"A","B","C","D","E","F","G","H","I","J"};
public static ArrayList CoOrdGen(Grid z) {
for (int i = 0 ; i < 10 ; i ++ ) {
yCordL.add(yCord[i]);
xCordL.add(xCord[i]);
}
for (int i = 0 ; i < 10 ; i ++ ) {
String letter = yCord[i];
for (int j = 0 ; j < 10 ; j ++ ) {
String number = xCord[j];
z.Avblcords.add(number + letter); // x + y
}
}
return z.Avblcords;
}
public static boolean MoveValidCheck(Grid inputer, ArrayList moves ) {
boolean valid = true;
ArrayList validList = new ArrayList();
for (int i=0 ; i < moves.size() ; i++ ) {
String move = (String) moves.get(i);
if (!inputer.Avblcords.contains(move) && (valid)) {
valid = false;
i = moves.size();
}}
if (valid) {
for(int i=0 ; i < moves.size() ; i++ ) {
inputer.Avblcords.remove(moves.get(i));
}
}
return valid;
}
}
import java.util.ArrayList;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class ShipClass {
ArrayList aC = new ArrayList();
ArrayList dS = new ArrayList();
ArrayList dS2 = new ArrayList();
ArrayList bS = new ArrayList();
ArrayList bS2 = new ArrayList();
ArrayList pB = new ArrayList();
ArrayList pB2 = new ArrayList();
ArrayList pB3 = new ArrayList();
ObservableList<ArrayList> shipsHealth = FXCollections.observableArrayList(aC,bS,bS2,dS,dS2,pB,pB2,pB3);
ArrayList moves = new ArrayList();
public ArrayList ShipPlacer (String shipType, String x, String y) {
int xIndex = Grid.xCordL.indexOf(x);
int yIndex = Grid.yCordL.indexOf(y);
moves.clear();
System.out.println(shipType + " "+ x + " " + y);
if (shipType == BSMain.ships.get(0) ) {
aC.add(Grid.xCordL.get(xIndex) + y);
aC.add(Grid.xCordL.get(xIndex+1) + y);
aC.add(Grid.xCordL.get(xIndex+2)+ y);
aC.add(Grid.xCordL.get(xIndex+3)+ y);
aC.add(Grid.xCordL.get(xIndex+4)+ y);
moves = aC;
System.out.println(aC.toString());
}
else if (shipType == BSMain.ships.get(1) ) {
bS.add(Grid.xCordL.get(xIndex)+ y);
bS.add(Grid.xCordL.get(xIndex+1)+ y);
bS.add(Grid.xCordL.get(xIndex+2)+ y);
bS.add(Grid.xCordL.get(xIndex+3)+ y);
moves =bS;
System.out.println(bS.toString());
}
else if (shipType == BSMain.ships.get(2) ) {
bS2.add(Grid.xCordL.get(xIndex)+ y);
bS2.add(Grid.xCordL.get(xIndex+1)+ y);
bS2.add(Grid.xCordL.get(xIndex+2)+ y);
bS2.add(Grid.xCordL.get(xIndex+3)+ y);
moves = bS2;
System.out.println(bS2.toString());
}
else if (shipType == BSMain.ships.get(3) ) {
dS.add(Grid.xCordL.get(xIndex) + y);
dS.add(Grid.xCordL.get(xIndex+1)+ y);
dS.add(Grid.xCordL.get(xIndex+2)+ y);
moves = dS;
System.out.println(dS.toString());
}
else if (shipType == BSMain.ships.get(4) ) {
dS2.add(Grid.xCordL.get(xIndex)+ y);
dS2.add(Grid.xCordL.get(xIndex+1)+ y);
dS2.add(Grid.xCordL.get(xIndex+2)+ y);
moves = dS2;
System.out.println(dS2.toString());
}
else if (shipType == BSMain.ships.get(5) ) {
pB.add(Grid.xCordL.get(xIndex)+ y);
pB.add(Grid.xCordL.get(xIndex+1)+ y);
moves = pB;
System.out.println(pB.toString());
}
else if (shipType == BSMain.ships.get(6) ) {
pB2.add(Grid.xCordL.get(xIndex)+ y);
pB2.add(Grid.xCordL.get(xIndex+1)+ y);
moves = pB2 ;
System.out.println(pB2.toString());
}
else if (shipType == BSMain.ships.get(7) ) {
pB3.add(Grid.xCordL.get(xIndex)+ y);
pB3.add(Grid.xCordL.get(xIndex+1)+ y);
moves = pB3;
System.out.println(pB3.toString());
}
else {
System.out.println("Type of ship not valid");
}
return null;
}
public void SunkCheck(ShipClass opponent) {
for (int i =0 ; i < opponent.shipsHealth.size() ; i++) {
if (opponent.shipsHealth.isEmpty()) {
System.out.println("All Ships Sunk");
}
else if (opponent.shipsHealth.get(i).isEmpty()) {
System.out.println("Target is sunk");
opponent.shipsHealth.remove(i);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment