mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
davhojt
1cf114eb85
|
1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago |
README.md
Chifoumi
Prerequisite
Create a file ChifoumiAction.java
and paste the following content :
public enum ChifoumiAction {
ROCK, PAPER, SCISSOR
}
Instructions
Create a file Chifoumi.java
.
Write a function getActionBeatenBy
that returns the action beaten by the action in parameter :
ROCK
will returnSCISSOR
PAPER
will returnROCK
SCISSOR
will returnPAPER
Use the switch
operator.
Expected Functions
public class Chifoumi {
public static ChifoumiAction getActionBeatenBy(ChifoumiAction chifoumiAction) {
// your code here
}
}
Usage
Here is a possible ExerciseRunner.java to test your function :
public class ExerciseRunner {
public static void main(String[] args) {
System.out.println(Chifoumi.getActionBeatenBy(ChifoumiAction.ROCK));
System.out.println(Chifoumi.getActionBeatenBy(ChifoumiAction.PAPER));
System.out.println(Chifoumi.getActionBeatenBy(ChifoumiAction.SCISSOR));
}
}
and its output :
$ javac *.java -d build
$ java -cp build ExerciseRunner
SCISSOR
ROCK
PAPER
$