Advertisement
fedotows

Communicator

Apr 27th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. package guess;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * @author Dimitrijs Fedotovs <a href="http://www.bug.guru">www.bug.guru</a>
  7.  * @version 1.0
  8.  * @since 1.0
  9.  */
  10. public class Communicator {
  11.     private static final Scanner scanner = new Scanner(System.in);
  12.  
  13.     static int askMaxNum() {
  14.         System.out.print("Please enter max number: ");
  15.         return scanner.nextInt();
  16.     }
  17.  
  18.     static void sayStartGame(int maxNum) {
  19.         System.out.println("I'm thinking a number from 1 to " + maxNum + ". Try to guess it!");
  20.     }
  21.  
  22.     static void sayNumLow() {
  23.         System.out.println("Your number is too low");
  24.     }
  25.  
  26.     static void sayNumHigh() {
  27.         System.out.println("Your number is too high");
  28.     }
  29.  
  30.     static void sayUserWon(int attempt) {
  31.         System.out.printf("You won! %d attempts were userd.\n", attempt);
  32.     }
  33.  
  34.     static void sayUserLost(int myNum) {
  35.         System.out.printf("You lost! My number was %d\n", myNum);
  36.     }
  37.  
  38.     static void sayGoodBye() {
  39.         System.out.println("Good bye!");
  40.     }
  41.  
  42.     static boolean askUserPlayAgain() {
  43.         System.out.print("Do you want to play again? (y/n) ");
  44.         return !scanner.next().equals("n");
  45.     }
  46.  
  47.     static int askUserNum(int attempt) {
  48.         System.out.printf("Attempt #%d. Enter your guess: ", attempt);
  49.         return scanner.nextInt();
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement