Download and add Pyschic.jar to the BlueJ library.
This jar file contains a package named Psychic,
which contains a class named PsychicFriend.
PyschicFriend objects contain a method
with the following signature: public String ask (String
), which can be used to pose questions to the PyschicFriend objects.
PsychicFriend objects respond with (return) an answer to
the question. Write a Java program which does the following:
- Declares and instantiates a
PsychicFriend object.
- Using the appropriate JOptionPane method, prompts the user for a
question for which the user wants an answer. Store the user's question in an
appropriately declared variable named question.
- Use the say method of the PsychicFriend object to
pass the question to the PyschicFriend object. Store
the PsychicFriend's answer in an appropriately declared variable named
answer. Your program thus functions as an intermediary between the
user and the PsychicFriend object.
- Using the appropriate JOptionPane method, display the answer
to the user.