Piet Souris wrote:If you look at the code in your opening post, the only thing that was missing
was in the 'else' branch. You needed a new value for the variable 'answer',
in order tp prevent getting into an infinite loop, in case the original 'answer'
was not 'y' or 'n'.
Junilu Lacar wrote:This wouldn't happen to be the same TextIO class you're using would it? http://math.hws.edu/javanotes/source/chapter10/TextIO.java
Junilu Lacar wrote:
Piet Souris wrote:For me, the code looks clear. True, it seems a bit sparse when it comes to
user communication, but apart from that...
Ok, assuming my sensitivity to code smells is just getting the best of me... or maybe I'm just not as forgiving as Piet.
I have reformatted the code to make it easier to read. Without making the assumptions that Piet has made about how this TextIO class works, I don't see where the variable answer, which I assume is a String, gets another value such that the loop can terminate. I don't see why there's a need to set the variable loop1 since it has no effect on anything inside this loop nor does it control the loop iteration.
I was thinking along the same lines about TextIO.putln() maybe having some way of getting user input but decided otherwise because of line 5. If the variable path is intended to be what its name implies, and based on the surrounding code, I would say that the putln method did not provide a way for the user to enter something. But I could be wrong.
Finally, I don't see why Mike would say "obviously, I need the loop to run 1 more time, after the last else statement" because if the last else statement were to be executed, then the loop would actually be executed at least one more time. Which brings me back to the question of "How does the variable answer get another value?" because without that happening, the if-else-if-else would just put you back in the last else and you would get into an infinite loop. Is that what's happening?
So, no, it's not really clear to me what exactly is happening unless I stretch my imagination and speculate about what this TextIO class is doing.
Stefan Evans wrote:Using a source control tool like git/svn would do what you are after.
Eclipse also maintains a "Local History" of changes to files. You can compare your current version against any version in the history, and recover the old one if you so wish using "Replace With"
Just right click any file in your project and look at the "Compare With" and "Replace With" options in the context menu.
Paweł Baczyński wrote:Get familiar with one of version control systems available.
I believe the most popular one right now is git.
Object serialization will allow you to save a state of an object, not a source code.
Stefan Evans wrote: