permaculture playing cards*
The moose likes Java in General and the fly likes Error in run method and class - help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error in run method and class - help!" Watch "Error in run method and class - help!" New topic
Author

Error in run method and class - help!

celine scarlett
Ranch Hand

Joined: Nov 06, 2005
Posts: 93
Hi,

I have wriiten the following BorrowerListManager class to provide management functions for a Borrower and BorrowerList class. However, I cannot get the 'run' method in this class to work, and consequently can't test whether it even works yet.

The problem is that the conditional statements within this class should call the appropriate methods, but I don't seem to be able to get these to work correctly.

My code so far is as follows,



All I'm trying to do is create a list and then be able to add, delete and search the borrowers. However, the manager class is proving a real pain.

If it will help, the code for my BorrowerList class is as follows,



I've really be struggling with this problem for days now, and any help would really be appreciated!!
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
Something is missing.

What class have the instance of BorrowerListManager?
How does that class invoke the run method?
The invoker could be a main method, start method, or another method?

Obviously the invoker is not in the code you provided.

What is the application? WEB, AWT or batch etc. If it is not very complicated search for a call to 'start'.
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
One small doubt.

Does any of your classes compiled?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
It really looks like you're trying to 're-create the wheel' with your
BorrowerList class.

If, in BorrowListManager, you had
Map borrowerList = new HashMap();

borrowList would already have the methods
put() - for add
get()
remove()
size()
etc()

only thing missing from your class is the i/o part, which doesn't belong in
the class anyway.

borrowerList could even be an ArrayList(), but you are likely to have
videoID's and/or memberID's, so a HashMap sounds an ideal candidate.
celine scarlett
Ranch Hand

Joined: Nov 06, 2005
Posts: 93
Hi,

Thanks for all the help. Both the Borrower and BorrowerList classes compile fine, it is only the BorrowerListManager class that is not working.

With regard to HashMaps, I haven't yet covered those so I'm not really sure what I would do with those. Basically, what is the best way to use the information in the BorrowerList and Borrower classes, as detailed below, to create a list in a text file so a user can add and delete a borrower, and of course search for them by membership number as and when required.

Current code for the classes is as follows,

1. Borrower class


2. BorrowerList class


Any advice or help really appreciated!!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> With regard to HashMaps, I haven't yet covered those so I'm not really sure what I would do with those.

here's a very basic example - quick'n'dirty (little or no error handling)

enter an id/name into the fields (e.g. 123 Fred)
click add
click show
add another couple of id/name's
click show

close program
open program
click show

type one of the id's into the id field
click delete
click show

celine scarlett
Ranch Hand

Joined: Nov 06, 2005
Posts: 93
Hi,

Thank you so much for all your help. I shall go through all of this today, and let you know how I get on with the program.

Many thanks and have a great week!!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in run method and class - help!
 
Similar Threads
Errors when reading and writing from a text file - any help!!
Reading strings from a line problem _ any help!!
How to return multiple strings of the same name from text file and array - any help
Calling a method from another class?
manager class with testing - any help please!!!