d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Gui Battleship Game Project > Need Serious Assistance!
Prev123Next
Add Reply New Topic New Poll
Member
Posts: 4,993
Joined: Aug 30 2009
Gold: 100.00
Apr 26 2010 11:08pm
Quote (Telecom @ Apr 26 2010 11:26pm)
Hows your implementation going? Need any other help?


it's on halt at the moment because of my final english paper. i spoke with my csc ta's and classmates, and from what i heard ship and square are the easy-to-do programs, and that battleboard is the tricky one.

i got ship done, and working on square, but i have a feeling i'm going to run into problems with battleboard.

if you have time to kill i was wondering if you could help me out on that one. if not i'll message you if i run into any difficulties.

thank you again for your assistance. if you have a price let me know and i'll see what i can do.
Banned
Posts: 3,326
Joined: Apr 25 2010
Gold: Locked
Trader: Scammer
Warn: 50%
Apr 26 2010 11:32pm
Quote (Skai20 @ Apr 27 2010 06:08pm)
it's on halt at the moment because of my final english paper. i spoke with my csc ta's and classmates, and from what i heard ship and square are the easy-to-do programs, and that battleboard is the tricky one.

i got ship done, and working on square, but i have a feeling i'm going to run into problems with battleboard.

if you have time to kill i was wondering if you could help me out on that one. if not i'll message you if i run into any difficulties.

thank you again for your assistance. if you have a price let me know and i'll see what i can do.


I don't charge for helping but donations are accepted. Basically PM me any questions or troubles you run into and ill see what i can do.
Member
Posts: 4,993
Joined: Aug 30 2009
Gold: 100.00
Apr 27 2010 01:31am
Quote (Telecom @ Apr 27 2010 01:32am)
I don't charge for helping but donations are accepted. Basically PM me any questions or troubles you run into and ill see what i can do.


alright!

and chances are I will donate ;)
Member
Posts: 2,624
Joined: Jan 5 2009
Gold: 1.09
Apr 27 2010 06:54am
I'm available for help aswell, had to write a battleships program in c for an assignment. wish i had it in java would have been twice as easy XD.
pm if you have any questions
Member
Posts: 4,993
Joined: Aug 30 2009
Gold: 100.00
Apr 27 2010 07:13am
Quote (kurkowski @ Apr 27 2010 08:54am)
I'm available for help aswell, had to write a battleships program in c for an assignment. wish i had it in java would have been twice as easy XD.
pm if you have any questions


Thank you! I will if I do!

This is the model portion of the MVC architecture of Java GUIs.

I'm working on my English paper for now, but I will hop on this as soon as possible!
Member
Posts: 4,993
Joined: Aug 30 2009
Gold: 100.00
Apr 29 2010 02:34pm
Update for everyone:

I finished Ship.java and Square.java

I need help on BattleBoard.java if anyone can help!

I need to know what to do after initializing the array of ships and squares.

also what numbers would i put for the traverse array?

Those are the top things I need to get started on this last portion. I also need general help with everything else too after ship and square!
Member
Posts: 2
Joined: Apr 30 2010
Gold: 0.00
Apr 30 2010 01:14am
I'd greatly appreciate if anyone could post the BattleBoard.java code. I have this exact same project due tomorrow and I'm stuck on this code. Thanks!

-Stuart
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Apr 30 2010 04:45am
Can you people list specific problems?
Member
Posts: 2
Joined: Apr 30 2010
Gold: 0.00
Apr 30 2010 05:53am
Code
public class BattleBoard {


private int[][] board;
private int numberOfShips;
private int length = 0;
private boolean isHorizontal = false;
private int startRow = 0;
private int startCol = 0;
private Square square;

public BattleBoard() {
 int BattleGame.ROWS = 8;
 int BattleGame.COLS = 8;
 int BattleGame.NUMBER_OF_SHIPS = 4;
 int [][] board = new int[BattleGame.ROWS][BattleGame.COLS];
  for(int i = 0; i < BattleGame.ROWS; i++) {
   for (int j = 0; j < BattleGame.COLS; j++) {
    board[i][j] = i + j;
   }
  }
 }

public boolean addShip(int length, boolean isHorizontal, int startRow, int startCol) {
 this.length = length;
 this.isHorizontal = isHorizontal;
 this.startRow = startRow;
 this.startCol = startCol;

}

public int getNumberOfShips() {
 return numberOfShips;
}

       //Don't know if this will work or not
public Ship[] getShips() {
 Ship [] myShip;
 while(square.hasShip() != false)
 {
  myShip = new Ship[10];
 }
 return myShip;
}

//Have no clue if this is right, but I think that's the general idea behind it
public boolean fireAtLocation(int row, int col) {
 if(square.getXPos() != row && square.getYPos() != col)
 {
  square.fireAt();
  return true;
 }
 if(square.hasBeenHit() == true)
 {
  return false;  
 }
}

       //Need Help with this one too
public boolean hasBeenHit(int row, int col) {
 if(square.getXPos() == row && square.getYPos() == col)
 {
  return true;
 }

 return false;
}


//Need Help with this one
public boolean areAllShipsSunk() {
 if(square.hasShip() != false)
 {
  return true;
 }
 
 return false;

}

public int getNumberOfRows() {
 return BattleGame.ROWS;
}

public int getNumberOfColumns() {
 return BattleGame.COLS;
}


       //Don't know how to write this
public String toString() {
 String noClue = "I don't know";
 return noClue;
}

}


I need help writing public Ship[] getShips(), public boolean fireAtLocation(int row, int col), public boolean hasBeenHit(int row, int col), public boolean areAllShipsSunk(), and public String toString() . Thanks in advance!

-Stuart
Member
Posts: 4,993
Joined: Aug 30 2009
Gold: 100.00
Apr 30 2010 06:32pm
Finished with this project!

This topic can be closed now!

If you have questions between one another in this thread please resort to PMs as they're more reliable :D
Go Back To Programming & Development Topic List
Prev123Next
Add Reply New Topic New Poll