Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add main method to this, to check if it works.

 
Laura Ruby
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I have this code :


And I need to test programm by addinf a main method and the calling getRoot method with a parameter to set result.

I know that i have to create a main method that would call the written function, but have no idea how to do it. Any help appreciated.thanks
 
Greg Brannon
Bartender
Posts: 563
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you said, there are at least 2 approaches: you can add a main() method to the existing class file, or you can create another class file whose sole function is to test the class file you posted. In either case, the main() method would look something like:


How you get aNumber or the other things you might do with the test instance to test it thoroughly are up to you.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47232
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Once you have the root approximation object Greg showed you, you can call its gteRoot() method and use the result however you wish.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic