Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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/
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic