Guest User

Untitled

a guest
Jan 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1. /////////////////////////////////////////////
  2.         //example from jonathan
  3.         BufferedReader reader;
  4.         int choice = 0;
  5.        
  6.         //print menu
  7.         while(choice != -1) {
  8.             System.out.println("What do you want to do?");
  9.             System.out.println("1. Add artist");
  10.             System.out.println("2. Add track");
  11.             System.out.println("3. Add Album");
  12.             System.out.println("-1: Exit the system");
  13.             //shouldnt be done in the loop
  14.             reader = new BufferedReader(new InputStreamReader(System.in));
  15.             System.out.print("Choice: ");
  16.            
  17.             try {
  18.                 choice = Integer.parseInt(reader.readLine());
  19.                 System.out.println(choice);
  20.             } catch (IOException e) {
  21.                 e.printStackTrace();
  22.             }
  23.            
  24.            
  25.             if(choice == 1) {
  26.                 //create new artist
  27.                 String name;
  28.                 String title;
  29.                 //ask for name
  30.                 System.out.print("Please enter artist name: ");
  31.                 name = getInput();
  32.                 //print blank line
  33.                 System.out.println();
  34.                 //ask for title
  35.                 System.out.print("Please enter the track title: ");
  36.                 title = getInput();
  37.                
  38.                 System.out.println("this is where we create an artist object with the name: " + name + " and title: " + title);
  39.                 //Artist artist = new Artist(name, title);
  40.                
  41.             } else if(choice == 2) {
  42.                 //create track
  43.                 //may need to keep a list of added artist objects in order to add an artist to a track
  44.             } else if(choice == 3) {
  45.                 //create album
  46.                 //may need to keep a list of added artist objects in order to add an artist to a track
  47.             } else if(choice == -1) {
  48.                 System.out.println("good bye");
  49.             }  
  50.         }  
  51.     }
  52.    
  53.     public static String getInput() {
  54.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  55.         String input = null;
  56.         try {
  57.             input = reader.readLine();
  58.         } catch (IOException e) {
  59.             e.printStackTrace();
  60.         }
  61.         return input;
  62.     }
Add Comment
Please, Sign In to add comment