Ahhh, thanks, that seems to work great :) I've made it set the sold cars fields to 0, then had my save car method skip over any lines with just 0.
Thanks again!
User Profile
Collapse
-
Thanks for the reply :)
Maybe I should explain about my program first, sorry last night I didn't really explain much.
The first thing that happens when the program is run, is the car details text file is loaded and convert into an object array. The coding used to do this is (the text file is opened with a BufferedReader previously, but I thought copying that code would be a bit pointless)
Code:Leave a comment:
-
Setting an object to blank?
Hi it's me again, I've pretty much finished a program I'm making, which does the following:
The program is for a garage, and it does the following functions:
Adds a new car
Display cars
Amend price of a car
Delete car ('sell' car)
Find a certain car
When the program is loaded, it attempts to read existing car data from a text file, which is then converted into an object array.... -
Just saying I'm pretty sure that the problem is this line:
Code:carDetails[search] = null;
Leave a comment:
-
Thanks for the replies :)
The line is actually in a different method, sorry I seem to have got confused! It's in the saveCarDetails method, but other methods also use this to save details, and they have no trouble. The saveCarDetails method is the following:
Code:public void saveCarDetails() throws IOException { { PrintWriter outputFile; outputFile
Leave a comment:
-
Deleting from a text file
Hi it's me again, I've pretty much finished a program I'm making, which does the following:
The program is for a garage, and it does the following functions:
Adds a new car
Display cars
Amend price of a car
Delete car ('sell' car)
Find a certain car
Almost everything is working perfect, except that I can't get the 'delete'f unction working correctly.
All the cars... -
The NullPointer references two methods: this line from the code I posted:
Code:carDetails[activeCars].setRegNo(tempRegNo);
If it's any help, this is the method for loading the car details, maybe I've messed up this.
Code:inputCarFile = Text.open ( textFilesPath + "car details.txt" );
Leave a comment:
-
Thanks for the reply :)
Yeah, I have this in the public class:
private static final int MAX_CARS = 10;
private Car [] carDetails = new Car[MAX_CARS];
and in the database currently is only 4 cars, so it hasn't reached the max :-?Leave a comment:
-
Inserting into an object
Hi, I am currently designing a program and I've run into a problem - It's probably really easy to solve, but heck it's late and I can't think lol.
I'm designing a program to store details of cars (i.e. a garage), and the car details are all stored in a text file, and the text file is terminated with ****. The program first loads the existing car details using a BufferedReader, then each cars details is converted into a position in... -
Wow, thanks for the speedy reply,t hat works perfect :) Thanks againLeave a comment:
-
Testing if a string is NOT equal to...
Hi, I'm currently coding a Java program for a University coursework, and I'm a little bit stuck.
How do I find out if a string is NOT equal to a certain value? I know to test if it is equal, you use .equals, but I have no idea how to test if it's not equal to.
Thanks
No activity results to display
Show More
Leave a comment: