Not very unclear, just rather dumb. The intended comparison (every attribute matters equally, the cat with a higher attribute gets 1 point with neither getting any in the event of a tie) is the only one that's accepted, and without knowing about Integer.compare the solution ends up being quite long and convoluted compared to all the other tasks in this lesson. Terrible problem overall.
No la entiendes porque no se ha explicado.
En Java (y en otros lenguajes como C, C++ y C#) hay un operador que se llama ternario:
(condicion) ? valor_si_verdadero : valor_si_falso;
Es una especie de if/else comprimido.
Si se cumple la condición, se ejecuta valor_si_verdadero; en caso contrario, se ejecuta valor_si_falso.
Espero que te ayude.
I don't like that you don't have to create classes here. I know the title of the page says "Practice creating objects" but in the individual tasks it says "Create the Person class." but the class is already written. In the previous lessons one had to re-type a whole program just for practice. I think it's easy enough as of now to write the class as well. The average number of attempts for this task is 1.18 and it reflects that it's too easy :).
Unsolicited advice --> I created a class demonstrating all the == between various string constructs, decimal/octal/binary/unicode ... why not give yourself simple tasks like creating the class in another editor for each assignment? Also, I'm not a fan of IDE reliance, so maybe couple that practice with using commandline, jdk and a text editor only. Write sh or bat(if on windows) to set CLASSPATH and JAVA_HOME and execute your programs using ant etc. There is a ton you can do along the way if you think it's too easy. You'll also get better at tailing logs etc so when you get a position you will not be reliant on an IDE or a web-based compiler ;)
If you have trouble with Implement the fight method, check how your code handles these additional cases:
1) If both cats have exactly same values.
2) If cat1 has 2 better values and 1 worse than cat2.
3) If cat1 has 1 better value and 2 worse than cat2.
GO TO FULL VERSION