Christopher.T Brown

Greenhorn
+ Follow
since Jul 08, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Christopher.T Brown

Are there any online resources that would help me develop the skills I need for the 808 - OCA 8? I would like to work on my programming skills while I study a book for the exam.

Norm Radder wrote:

The text files now get created. But, the files are empty.  


What is written to the console when the program executes?

There needs to be more info printed on line 32.  Add fileName and saveState to the println() statement so you can see what the code sees when it executes.

I don't see a close() so the buffer isn't being written to disk.
Also see http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html



Norm, it worked!! Thank ya!
7 years ago

Norm Radder wrote:

The text files now get created. But, the files are empty.  


What is written to the console when the program executes?

There needs to be more info printed on line 32.  Add fileName and saveState to the println() statement so you can see what the code sees when it executes.



Hey Norm. Everything is passed as it should be:

File written
ttt.txt


File written
cf.txt


File written
mm.txt


BUILD SUCCESSFUL (total time: 0 seconds)
7 years ago

Norm Radder wrote:From line 4:

Note: Using the length of the first row (cells[0].length() ) assumes that all the rows have the same length.

It might be better to use the code from line 39 that uses the length of the current row:



I've made a tad bit of progress. The errors are gone. The text files now get created. But, the files are empty. I pass the array(Board) to the method, writeToFile, as a string. All I need it to do is print to the text file, but it looks as though the BufferedWriter is null. Any advice. Ya'lls help thus far has been invaluable. Thanks!

BoardGameTester:


FileManager:


7 years ago

Norm Radder wrote:

it is not generating the output files.  


Are the statements on line 30 and 31 being executed?

Is the problem that the files are created but they are empty or are the files not being created?



Hey Norm,

The files are not being created. I inserted a System.out.println(line) in the try block, and I did not receive any output.

Chris
7 years ago

Norm Radder wrote:


Exception in thread "main" java.lang.NullPointerException
at games.board.Board.toString(Board.java:40)  


Look at line 40 and find the variable with the null value.  Then backtrack in the code to see why that variable does not have a valid value.
You might need to print the values of the variables: "r" and c to see where they refer.

Also the Arrays class's deepToString() method is useful for showing the contents of a 2 dim array for debugging:

NOTE to forum moderators:  I was unable to refer to the variable "r" without the "s.  The forum software wanted to see "are" not the "r" without quotes.



Thanks! I was referencing the "r" counter to process the c counter. I no longer experience build errors, but it is not generating the output files. I am attempting to do start a new thread in FileManager and create the output files. The FileManager code is as follows:

7 years ago
I am trying to print three game boards to a text file. Could you please point me in the right direction? (No pun intended:) I have marked the lines of code referenced in the errors.

Error:
run:
Tic Tac Toe game board
Connect Four game board
Mastermind game board
Exception in thread "main" java.lang.NullPointerException
at games.board.Board.toString(Board.java:40)
at boardgametester.BoardGameTester.main(BoardGameTester.java:45)
C:\Users\Chris\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)

Board.java


BoardGameTester.java
7 years ago
Thanks, fellas. Vijay, you were right on the money. It fixed that error. I have since fixed an OutOfBoundsException on the array. I now have a NullPointerException. I have researched the issue, and what I've learned is that I'm referencing an object that doesn't exists. I cannot figure out what object it may be. So, here's my code and the compile error. Thanks again!





Error:
run:
Tic Tac Toe game board


Connect Four game board
Exception in thread "main" java.lang.NullPointerException
at games.board.Board.toString(Board.java:47)
at boardgametester.BoardGameTester.main(BoardGameTester.java:37)
C:\Users\Chris\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
7 years ago
I am working on a newbie project and I have a problem I cannot resolve. I have deleted the Netbeans cache, recreated the problem child, and turned on/off Compile on Save(?). The problem is this: The setCell method is not seen in the BoardGameTester. I get "Symbol not found". I am going to post the problem code and the error message. Thanks in advance for your time and any help in advance. PS- Please be kind as I am new to this site. If I have posted the code incorrectly, just let me know how to do it and I will repost.

Error:
run:
Tic Tac Toe game board
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: Array.setCell
at boardgametester.BoardGameTester.main(BoardGameTester.java:32)
C:\Users\Chris\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 5 seconds)

Code:

7 years ago