You have complete control of what your methods do with their input parameters. You also have control over wether your methods return something, Sting for example or nothing i.e void There is no fixed rule that a method must include code that writes to output. Please post your code and explain what you are trying to do and we will try and help
Is it possible to add a boolean parameter to your function?
if so, you'd have
note that you could still have a version that didn't have the boolean:
this way, you could leave all the calls that you already have that you DO want to print alone, and just change the ones where you don't want to print to HAVE the third parameter with FALSE as the value for param 3
did that make ANY sense??? [ November 24, 2004: Message edited by: fred rosenberger ]
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
There's any number of ways you could do this. This is just one example
The object of class SomeClass would be created with printing disabled. You could call setSomeField() as often as you liked, changing the value of the field each time. When you call setPrintingStatus() with the parameter set to "true," the program will output the field to the system's output stream.
Keeping track of the object's internal state is what fields are for. Generally, it is a good idea to use methods to change field values (rather than making the fields themselves directly available by making them public).
Hope this helps!
Joined: Oct 04, 2004
Haven't got any code I was just thinking of a way that I could do it rather than writing two separate methods.
I would rather write two methods. If you would like to improve as a programmer, one important principle you should learn is the One Responsibility Rule. If a method needs to do calculations, that's all it should do. If it needs to display things, it should only display things. Ne'er the twain shall meet. To put conditionals in the method to control whether it will display things or not is kludgy at best, IMO.