A point of confusion has been how codeHS asks for input and how we have been asking for input. If you try to use the Read class in our programs you’ll probably notice it doesn’t work.
The Read class used in CodeHS is really just hiding a Scanner behind the scenes. It’ll take a String as a parameter, use that as the prompt to the user, and then it uses a Scanner to retrieve the input.
1. You will need to make a class called Read. 2. Import a Scanner and instantiate it globally. 3. The constructor should print a message saying the Read class has been created.
Each one of these methods takes a String that is the prompt as an argument, prints the prompt to the user, and then uses a Scanner to get the actual input, then returns the input from the user.
1. From CodeHS version: readInt(String prompt), readDouble(String prompt), readBoolean(String prompt), readLine(String prompt).
2. Our read additions: readWord(String prompt), readChar(String prompt).
3. Non-read additions: enter(), toString()
The enter method should take no arguments and no return type. It prints a message about how the user can press enter to continue, and then uses the Scanner .next() method to allow the user to press a button. We do not even need to store this value. It can be helpful sometimes to control the flow of your game by getting an enter here and there.