This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Here is my filereader so far, I have got a readout from the txt file, but am having problems adding them to arrayLists. I have added the following but then taken it out as it doesn't seem to work, which I think is a problem with my constructor in Car.java. Any tips on setting up the constructor?
EDIT by mw: Added Code Tags. [ January 19, 2007: Message edited by: marc weber ]
Try using code tags when posting code in future - it makes it easier to read. Having said that I can see a couple of problems.
You declare carlist as an ArrayList that contains Strings, but you are adding Car objects to it. Change the declaration to
Later on in your code you try to assign a Car object to carlist
Get rid of the middle line, not only is it wrong, you don't need actually need it as you have already created your ArrayList.
Make those changes and if it still doesn't work, tell us what the problem is - if it doesn't compile tell us what the error messages are - if it doesn't do what you want, tell us what it is doing and what you expected it to do.
Joined: Nov 23, 2006
Thanks, I have made those changes, however I still have a Car class with no constructor as I'm not sure what to write. Also the following compilor errors have come up:
3 errors found: File: C:\Documents and Settings\Lari\My Documents\Huddersfield\Programming\Coursework2\DemoFileReader.java [line: 61] Error: cannot find symbol symbol : constructor Car(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) location: class Car File: C:\Documents and Settings\Lari\My Documents\Huddersfield\Programming\Coursework2\DemoFileReader.java [line: 61] Error: internal error; cannot instantiate Car.<init> at Car to () File: C:\Documents and Settings\Lari\My Documents\Huddersfield\Programming\Coursework2\DemoFileReader.java [line: 62] Error: non-static variable carList cannot be referenced from a static context
Lines 61/2 = Car car = new Car(reg, make, model, colour, passenger_no); carList.add(car);
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com