Advertisement
daixso

Player_Names class

Aug 2nd, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. //get the player name and greet them
  2. import java.util.*;
  3. public class Player_Names {
  4.     public Scanner input = new Scanner(System.in);
  5.     public String name = "";
  6.     public Player_Names(){
  7.         PlayerNames();
  8.     }
  9.     public void PlayerNames(){
  10.         System.out.print("Please enter your name: ");
  11.         name = input.nextLine();
  12.         System.out.println(name +  "? Is this correct? Y/N ");
  13.         String correct = input.nextLine();
  14.         if(correct.toLowerCase().equals("y") || correct.toLowerCase().equals("yes")){
  15.             System.out.println("Name saved!");
  16.         }else if(correct.toLowerCase().equals("n") || correct.toLowerCase().equals("no")){
  17.             PlayerNames();
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement