Advertisement
Guest User

Untitled

a guest
Jul 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class games_project {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner userinput = new Scanner(System.in);
  8.  
  9. String full_name = "James Burton";
  10. String full_name2 = "Brian Ross";
  11. String full_name3 = "Bill Gates";
  12. String password = "thomas";
  13.  
  14. System.out.println("Please sign in.");
  15. System.out.println("Full name, please: ");
  16.  
  17. boolean game = true;
  18.  
  19. while (game) {
  20.  
  21. String username;
  22. username = userinput.nextLine();
  23.  
  24. if (username.equalsIgnoreCase(full_name) || username.equalsIgnoreCase(full_name2) || username.equalsIgnoreCase(full_name3)) {
  25.  
  26. System.out.println("Hello, " + username + ".");
  27. break;
  28.  
  29. } else {
  30. System.out.println("Sorry that was incorrect try again.");
  31. }
  32.  
  33. }
  34.  
  35. System.out.println("Please enter your password: ");
  36.  
  37. boolean pass = true;
  38.  
  39. while (pass) {
  40.  
  41. String check;
  42. check = userinput.next();
  43. if (check.equals(password)) {
  44. System.out.println("Welcome.");
  45. break;
  46. } else {
  47. System.out.println("Sorry that was incorrect. Try again.");
  48. }
  49. }
  50.  
  51. System.out.println("Let's get started, shall we? What game would you like to play?");
  52. System.out.println("1) Checkers");
  53. System.out.println("2) Connect Four");
  54. System.out.println("3) Minesweeper");
  55.  
  56. boolean games = true;
  57.  
  58. while (games) {
  59. String game_choice;
  60. game_choice = userinput.next();
  61. if (game_choice.equalsIgnoreCase("Checkers") || game_choice.equals("1")) {
  62. System.out.println("Ok. Enjoy checkers.");
  63. break;
  64. } else if (game_choice.equalsIgnoreCase("connect four") || game_choice.equals("2")) {
  65. System.out.println("Ok. Enjoy connect four.");
  66. break;
  67. } else if (game_choice.equalsIgnoreCase("minesweeper") || game_choice.equals("3")) {
  68. System.out.println("Ok. Enjoy minesweeper.");
  69. break;
  70. } else {
  71. System.out.println("Sorry, please type in either the game name or the number besides it. Thank you!");
  72. }
  73.  
  74.  
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement