|
-
February 19th, 2013, 06:06 PM
#1
Battleship program- need help
First off, hello everyone.
For a class project i must write a text based Battleship program. I am getting a NullPointerException in the following code and im not sure why exactly. I have 3
classes: Game, SingleSpace, and Grid. The Grid object is a 2D array comprised of SingleSpace objects. And the Game is where my main function is.
So heres a bit of the code. I am pretty new so it may be poorly coded.
I originally had the array of type int but my professor wants us to have space objects so i figured that meant to have the array of type space.
It worked when it was type int, but since i switched it to SingleSpace array, i am getting the error
Space class.pngGrid class.pngMain.png
Here is the error:
Exception in thread "main" java.lang.NullPointerException
at Grid.<init>(Grid.java:13)
at Game.main(Game.java:12)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|