runfaster's Profile
Reputation: 14
Tradesman
- Group:
- Active Members
- Active Posts:
- 135 (0.09 per day)
- Joined:
- 23-January 09
- Profile Views:
- 3,504
- Last Active:
Mar 24 2013 02:01 PM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Windows
- Favorite Browser:
- FireFox
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- PC
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Latest Visitors
-
.Aaron 
22 Jan 2013 - 16:33 -
t_dream_in_1000 
08 Mar 2012 - 17:51 -
supr4 
03 Mar 2012 - 08:04 -
brep 
25 Sep 2011 - 14:28 -
Dogstopper 
13 May 2011 - 02:30
Posts I've Made
-
In Topic: Battleship program
Posted 19 Feb 2013
I'd say you're getting the NullPointer because you haven't initialized the SingleSpace objects in your Grid. You need to initialize them before trying to operate on them, otherwise you're trying to perform the operation on a null object, and thus throwing the exception.
So, a fix for that might look something like this:
public Grid(int rows, int cols){ for(int i = 0; i < 10; i++){ for(int j = 0; j < 10; j++){ playerBoard[i][j] = new SingleSpace(); playerBoard[i][j].setValue(-1); } } }
You also have other issues with how big you want your constructor to make the Grid. You currently have 3 options in your code: the two constants ROW and COLS, hard coded values in the for loops, and passed parameters. It's best to decide on this now, so as to avoid confusion later.
EDIT: The reason it worked when using int is that int has a default value of zero, as discussed here. Objects have a default value of null. -
In Topic: Tossing a coin
Posted 14 Feb 2013
Here's a relevant link to a description of the method: W3 School Page
I would look at that, and look at your if statement in flip(). Your comparison is your problem.
Pay special attention to the range of the random method and the fact that you want a given result half of the time.
That's all I've got for you at a glance. For displaying results, however, someone else will have to help you. Unfortunately, I'm not that familiar with javascript. -
In Topic: Test Driven Development, do you use it?
Posted 12 Feb 2013
The job I just started really promotes this style of coding, but didn't use it at all in college. Thus, I put "No, (some other reason).
It's quite a struggle to try and flip your mindset to test-driven when you're not used to it, but I can certainly see the benefits. Knowing what you have to satisfy, test-wise, is definitely a good way to approach a development problem. I'm definitely going to try and use it going forward. -
In Topic: Form not finding elements
Posted 23 Apr 2012
Alright. So that markup invalidator site is cool! Didn't know about that.
Anyway, after fixing that, stuff, I moved the beginning and end of the form outside of the div, and things worked. Thanks a bunch, again, for the help! -
In Topic: Form not finding elements
Posted 23 Apr 2012
I'll shoot you a pm with the link. At this point, it's not hooked up to anything important, so go nuts. The body of the page is php generated, so if you want to see how that stuff is generated, let me know. Thanks a bunch!
My Information
- Member Title:
- D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Location:
- Kansas
- Interests:
- Marching Band, Programming, Gaming, Reading, D&D, and German Language
- Full Name:
- Charlie Allen
- Years Programming:
- 69
- Programming Languages:
- C, C++, C#, Java, some Python, SML, and Prolog
Contact Information
- E-mail:
- Private
- Website URL:
-
http://
Friends
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
runfaster has no profile comments yet. Why not say hello?