reset password
Author Message
stridhiryu030363
Posts: 37
Posted 17:57 Feb 10, 2012 |

I don't understand this part.
"A constructor which reads the test entries from a file, and store them in an ArrayList of TestEntry objects."

Do I make a main function to do that or is there something that I'm missing?

stridhiryu030363
Posts: 37
Posted 18:23 Feb 10, 2012 |

Ok, I don't understand using beans at all. I have my TestEntry class all done, what I don't understand is how to setup the "TestBean" to read text files and making TestEntry array objects out of them.

stridhiryu030363
Posts: 37
Posted 03:01 Feb 11, 2012 |

Ok, still truly lost. Tried making a setter(readFile) with a scanner function looking into the text file,entering everything into my arraylist, line by line, with the filename as the argument. Don't know if it's completely correct but it makes some sense looking over it. Attempted to use a getter but I don't really understand how to manipulate the data that should be returned from it. I completely give up until I think of something later today. Been looking through the book and the lecture code for hours but I can't seem to get a clear understanding of what I should be doing.

cysun
Posts: 2935
Posted 07:43 Feb 11, 2012 |

You do know what a "constructor" is, right?

M_Hsu
Posts: 19
Posted 12:36 Feb 11, 2012 |

What I did was used a bufferedReader in the TestBean constructor 

public TestBean()

and read the lines in the txt file, adding TestEntry objects to the ArrayList with the read in values as parameters

stridhiryu030363
Posts: 37
Posted 13:34 Feb 11, 2012 |

Yes I know what a constructor is. I just didn't really know how to use one to make it read txt files though. Which brought me to my initial question. My knowledge of java isn't that strong right now.

As for M_Hsu statement, as soon as you use the usebean function in the jsp, it'll execute everything in the constructor including reading and saving the text file into the array list, right?

Last edited by stridhiryu030363 at 13:35 Feb 11, 2012.
M_Hsu
Posts: 19
Posted 13:50 Feb 11, 2012 |
stridhiryu030363 wrote:

Yes I know what a constructor is. I just didn't really know how to use one to make it read txt files though. Which brought me to my initial question. My knowledge of java isn't that strong right now.

As for M_Hsu statement, as soon as you use the usebean function in the jsp, it'll execute everything in the constructor including reading and saving the text file into the array list, right?

Exactly. No need for any parameters for the bean

stridhiryu030363
Posts: 37
Posted 13:52 Feb 11, 2012 |

Thanks. That's what I really needed to know.

M_Hsu
Posts: 19
Posted 13:53 Feb 11, 2012 |

Use a bufferedReader

stridhiryu030363
Posts: 37
Posted 22:47 Feb 11, 2012 |

Ok, some progress today. I have the contents of the text file in the array and had the first question with it's choices printing on screen in the jsp. Trying to figure out how collect data from the radio buttons,  how to advance to the next question, the use of lastEntry, tabulating the results with score, and the use of jstl in general(there's nothing in the book, as far as I know). This is just a lab but it's taking significantly more time than both the homework assignments we had combined due to the two new elements(javabeans and jstl).

Although it seems like I'm the only one having problems with this, I'm making an honest effort to complete the assignments for the overall completion of the course and need assistance.