I have a ToString() method I need to run but need to use loops instead of if and else statements. How should i do it?
public String toString()
{
if (collectedDots == 0)
return "Player[]"+"("+x+","+Math.abs(y)+")";
else if (collectedDots == 1)
return "Player["+"*"+"]"+"("+x+","+Math.abs(y)+")";
else if (collectedDots == 2)
return "Player["+"**"+"]"+"("+x+","+Math.abs(y)+")";
else
return "Player["+"***"+"]"+"("+x+","+Math.abs(y)+")";
}