Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. package javaapplication43;
  2.  
  3. import java.io.File;
  4. import java.util.Scanner;
  5. import java.io.FileInputStream;
  6. import java.io.IOException;
  7. import java.io.FileNotFoundException;
  8. import javax.swing.JOptionPane;
  9.  
  10. public class javaapplication43 {
  11.  
  12. public static Scanner rfid = new Scanner(System.in);
  13. static int animalOption, habitatOption, exit, userChoice, userChoice2;
  14.  
  15. public static void main(String[] args) throws FileNotFoundException {
  16.  
  17. printHeader();
  18. printMenu();
  19. takeInput();
  20. //animalStuff();
  21. selectAnimal();
  22. printMenu2();
  23.  
  24. }
  25.  
  26. private static void printHeader() {
  27. System.out.println("+------------------------------+");
  28. System.out.println("| WELCOME MENU |");
  29. System.out.println("| |");
  30. System.out.println("+------------------------------+");
  31. }
  32.  
  33. private static void printMenu() {
  34. System.out.println("");
  35. System.out.println("Would you like to: ");
  36. System.out.println("");
  37. System.out.println("1: Monitor an animal ");
  38. System.out.println("2: Monitor a habitat ");
  39. System.out.println("3: Exit");
  40. }
  41.  
  42. private static void takeInput() {
  43. boolean conditionMet = false;
  44.  
  45. while (conditionMet == false) {
  46. userChoice = rfid.nextInt();
  47.  
  48. if (userChoice == 1) {
  49. System.out.println("Monitor an animal.");
  50. conditionMet = true;
  51. } else if (userChoice == 2) {
  52. System.out.println("You are currently monitoring a habitat.");
  53. conditionMet = true;
  54. } else if (userChoice == 3) {
  55. System.out.println("Goodbye!");
  56. System.exit(0);
  57. } else {
  58. System.out.println("Try again.");
  59.  
  60. }
  61. }
  62. }
  63.  
  64. private static void printMenu2() {
  65. System.out.println("");
  66. System.out.println("Select an animal: ");
  67. System.out.println("");
  68. System.out.println("1: Lions ");
  69. System.out.println("2: Tigers ");
  70. System.out.println("3: Bears ");
  71. System.out.println("4: giraffes ");
  72. }
  73.  
  74. private static void selectAnimal() {
  75. boolean conditionMet2 = false;
  76.  
  77. while (conditionMet2 == false) {
  78. userChoice2 = rfid.nextInt();
  79.  
  80. if (userChoice2 == 1) {
  81. System.out.println("Select lion.");
  82. conditionMet2 = true;
  83. } else if (userChoice2 == 2) {
  84. System.out.println("Select tiger.");
  85. conditionMet2 = true;
  86. } else if (userChoice2 == 3) {
  87. System.out.println("Select Bear.");
  88. conditionMet2 = true;
  89. } else if (userChoice2 == 4) {
  90. System.out.println("Select giraffes.");
  91. conditionMet2 = true;
  92. } else if (userChoice2 == 5) {
  93. System.out.println("Goodbye!");
  94. System.exit(0);
  95. } else {
  96. System.out.println("Try again.");
  97.  
  98. }
  99. }
  100. }
  101.  
  102.  
  103.  
  104. //private static void animalStuff() throws FileNotFoundException {
  105.  
  106.  
  107.  
  108. // File text = new File("\\Users\\che\\Documents\\NetBeansProjects\\JavaApplication43\\src\\javaapplication43\\animals.txt");
  109.  
  110.  
  111.  
  112. //Scanner scnr = new Scanner(text);
  113.  
  114. //String animalSelection;
  115. //int lineNumber = 1;
  116. //while (scnr.hasNextLine()) {
  117.  
  118. //animalSelection = scnr.nextLine();
  119. //if (animalSelection.contains("*****")) {
  120. //JOptionPane.showMessageDialog(null, animalSelection, "contains *****", JOptionPane.INFORMATION_MESSAGE);
  121. // break;
  122. }
  123. //lineNumber++;
  124. // }
  125. //}
  126.  
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement