Click here to Skip to main content
15,916,180 members

Comments by Malcolm Chambers (Top 4 by date)

Malcolm Chambers 11-Nov-14 0:21am View    
Did you create tests to verify that the code works as you expect, I know that several languages are libel to evaluate the newline method each time the case statement is evaluated. So just because it produce the correct response for "test 1" does not mean that it works for the others.

You need to execute each case to verify that it produces the correct value.

But I guess it depends on the marking scheme. I would likely fail the code if I was marking it, because it is such poor practice.

Also not Java programmer.
Malcolm Chambers 23-Oct-14 14:40pm View    
I am glad that you solved your method but do you agree that using recursion results in a solution that is much clearer.
Malcolm Chambers 22-Oct-14 22:10pm View    
Yes I did put the words around the wrong way. This is the first time that I have been tempted to respond and provide my insight to a posted issue. Certainly when I tested his code I did only create a test project. I guess I was assuming (I know always a risk) that the code lived in a project, and that good practice is that you don't embed unit tests directly into any other project type.
Malcolm Chambers 22-Oct-14 20:44pm View    
First things First you don't need to write an entire program but you do need to write some tests, add a test solution to your project and then you can test fragments with out having to write an entire program. I have done that and developed some tests.

Secondly And as written the only case that work are 1 item in list and that is kind of suspect as it is undefined behavior.