Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package guess;
- import java.util.Scanner;
- /**
- * @author Dimitrijs Fedotovs <a href="http://www.bug.guru">www.bug.guru</a>
- * @version 1.0
- * @since 1.0
- */
- public class Communicator {
- private static final Scanner scanner = new Scanner(System.in);
- static int askMaxNum() {
- System.out.print("Please enter max number: ");
- return scanner.nextInt();
- }
- static void sayStartGame(int maxNum) {
- System.out.println("I'm thinking a number from 1 to " + maxNum + ". Try to guess it!");
- }
- static void sayNumLow() {
- System.out.println("Your number is too low");
- }
- static void sayNumHigh() {
- System.out.println("Your number is too high");
- }
- static void sayUserWon(int attempt) {
- System.out.printf("You won! %d attempts were userd.\n", attempt);
- }
- static void sayUserLost(int myNum) {
- System.out.printf("You lost! My number was %d\n", myNum);
- }
- static void sayGoodBye() {
- System.out.println("Good bye!");
- }
- static boolean askUserPlayAgain() {
- System.out.print("Do you want to play again? (y/n) ");
- return !scanner.next().equals("n");
- }
- static int askUserNum(int attempt) {
- System.out.printf("Attempt #%d. Enter your guess: ", attempt);
- return scanner.nextInt();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement