• Post Reply Bookmark Topic Watch Topic
  • New Topic

Main Method Help  RSS feed

 
Thomas N. Williams
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there. Relatively new to Java. I have an assignment which is split into parts, based on a username/password idea. First part was to create a data structure appropriate for my project and I could add items to it. Done this using a Binary Search Tree. There appears to be no error in the code, but I can't figure out how to create a main method to make sure it works properly.
Code:


Any help with a main method would be greatly appreciated, grateful for any other suggestions or improvements. Thanks
 
Bert Wilkinson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thomas. A couple ideas to chew on:

First, your BST is tough to read, because you are incorporating 2 ideas into one class, where it would probably make more sense to break this into 2 classes: One for nodes in your tree, the other for the tree itself.... then the methods associated with each of these concepts (new nodes or adding to the tree) would be contained in their respective classes. this will make your code MUCH more readable.

There's a few issues with your code, that you should be able to work out after you start testing it. Lots of recursion in there for someone who doesn't have a grip on how to incorporate a main to test with, though...are you sure it's all yours?

To get you started, you can make a separate class or just write a main method within you current class to make it executable...then just declare your tree variable and have at it.

 
Janeice DelVecchio
Bartender
Posts: 1812
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas, welcome to JavaRanch!

You might find this article interesting and maybe useful, conceptually....
http://javaboutique.internet.com/tutorials/UnitTesting/
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!