• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Main Method Help

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic