Tags | functional-interface lambda-expressions |
Hard Prerequisites | |
IMPORTANT: Please review these prerequisites, they include important information that will help you with this content. | |
|
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
├── main
│ └── java
│ └── FunctionalInterfaceDemo.java <-------- names are important
└── test
└── java
└── FunctionalInterfaceDemoTest.java <-------- names are important
Create a class called FunctionalInterfaceDemo
which implements methods called isOdd
, isPalidrome
and isPrime
. Each of the methods should return a lambda expression.
isOdd
: The lambda expression must return true if a number is odd or false if it is even.
isPalindrome
: The lambda expression must return true if the number is Palindrome (12321) or false if it is not a Palindrome
isPrime
: The lambda expression must return true if the number is Prime (3) or false if it is not a not Prime (4)
Create a main method that gets a number from the standard input and then prints a message describing the value.
Once this message has been printed out then the user should be able to enter another number and then prints another descriptive message.
This should repeat until the user enters q
to quit the program.
Here are some examples of descriptive messages for different numbers:
Number is: Odd, Palindrome and NotPrime
Number is: Odd, NotPalindrome and Prime
Number is: Even, Palendrome and NotPrime
Hint: Think about how you could make use of the above examples in your unit tests.