Advertisement
daixso

Player_Names class

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