Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Damien Bell <SkyeShatter@gmail.com>
- */
- public class Arrays {
- private char[][] Arrays;
- private boolean used;
- public Arrays(char[][] PlayerArray) {
- Arrays = PlayerArray;
- }
- public void AddBoatVert(int x, int y, int z, char boatLetter) {
- int i, j;
- for (i=0; i<z; i++){ // while I < SelectedBoat.health, increment i
- if (Arrays[y][x]!=' '){ // if X / y do not = default value
- System.out.println("Oh dear, it seems as though there is a collision at location: "+Boatloc.ReverseBoatLoc(y, x)+ "Please try another location");// There is a collision at location x/y
- for (j=0; j<i; j++){ // for counter j < counter i
- if (i > 0){//
- y--;
- Arrays[y][x]=' ';
- }
- else if (i<=0){
- break;
- }
- }
- }
- else {
- Arrays[y][x]= boatLetter;
- y++;
- }
- }// End for
- }
- public void AddBoatHoriz(int x, int y, int z, char boatLetter) {
- int i;
- for (i=0; i<z; i++){
- if (Arrays[y][x]!=' '){
- System.out.println("Oh dear, it seems as though there is a collision at location: "+Boatloc.ReverseBoatLoc(y, x));
- x++;
- for (i=0; i<z; i++){
- Arrays[y][x]=' ';
- }
- }
- else{
- Arrays[y][x]= boatLetter;
- x++;
- }
- }
- }
- public static void DisplayMap(char[][] Array){
- //Player Grid Output.
- int i=0, j=0;
- System.out.println("____________Player setup:____________\n"); // Top of the 'player positioning' box.
- System.out.println(" A B C D E F G H I J"); // Top of grid letters
- System.out.println("");// blank line
- for (i=0; i < Array.length; i++){ // Outer loop of the 2d array output
- if (i< 9){
- System.out.print("| "+ (i+1) +" "); // Left side of the box
- }
- else{
- System.out.print("| "+ (i+1) +" ");
- }
- for (j=0; j<10; j++){ // Inner loop of array
- System.out.print(Array[i][j]+ " "); // Array output
- }// End inner for.
- System.out.println(" |"); // Right side of playermap box
- }//End outer for
- System.out.println("______________________________________"); // Formatting-- Bottom of box
- }
- public static boolean ArrayCheckPlayer(boolean[][] boolarray, int x, int y){
- boolean BoolCheck=false;// Set default boolcheck to false, or spot-unoccupied
- if (boolarray[x][y]==false){
- BoolCheck=false; // False means the spot is occupied already
- }
- else if(boolarray[x][y]==true){
- BoolCheck=true; // Spot is used.
- }
- return BoolCheck;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement