Wednesday, 15 July 2015

junit - Trouble with assertEquals (Java) -


I'm trying to make a game of "rock, paper, scissors". I have such tests:

  @Test Public Zero Rockbatscissors () {assertEquals (rock, rock.vs (scissors)); }  

I think it should be enough to form a function, for example:

  Public square rock {Object vs (scissors) } Rock(); } Object vs (Paper P) {Return new paper (); } Object vs (Rock R) {New Rock (Return); } Boolean equivalent (rock R) {return true; } Boolean equivalent (Paper P) {return false; } Boolean par (scissors) {return false; }}  

(I know that I should add the Hashkod function, by the way) I run the test and only I get the failure. What am i doing

equal () code> emphasis () Which takes object as the argument. Right now, you have not overridden the object # equals () method, but use your own 3 equal method, which will not even be used, and thus the default The object class method is used, which compares the context.

You have to give the following implementation:

  / ** * Terrible 'par ()' method implementation. Just for display purpose * / @ Override public boolean equivalent (object oBJ) {Oz example for returning to rock; }  

No comments:

Post a Comment