Suppose I have a function which takes in two values and returns one value, as per the rule:
(x,y) should return y
(y,z) should return z
(z,x) should return x
(y,x) should return y
(z,y) should return z
(x,z) should return x
How to I store these cases? The ordering of the parameters do not matter. I do not want to use a series of nested if else statements
You are trying to code scissors, paper, stone. For a long answer to your problem, look here: http://rosettacode.org/wiki/Category:Java.
Understanding the code in the
enumsection and thewhileloop inrun()on that page should help you to distil the code into a method you can use