Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //get the player name and greet them
- import java.util.*;
- public class Player_Names {
- public Player_Names(){
- PlayerNames();
- }
- public void PlayerNames(){
- Scanner input = new Scanner(System.in);
- System.out.print("Please enter your name: ");
- String name = input.nextLine();
- System.out.println(input + "? Is this correct? Y/N ");
- String correct = input.nextLine();
- if(correct.toLowerCase()=="y" || correct.toLowerCase()=="yes"){
- System.out.println("Name saved!");
- }else if(correct.toLowerCase()=="N" || correct.toLowerCase()=="no"){
- PlayerNames();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement