Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////////////////
- //example from jonathan
- BufferedReader reader;
- int choice = 0;
- //print menu
- while(choice != -1) {
- System.out.println("What do you want to do?");
- System.out.println("1. Add artist");
- System.out.println("2. Add track");
- System.out.println("3. Add Album");
- System.out.println("-1: Exit the system");
- //shouldnt be done in the loop
- reader = new BufferedReader(new InputStreamReader(System.in));
- System.out.print("Choice: ");
- try {
- choice = Integer.parseInt(reader.readLine());
- System.out.println(choice);
- } catch (IOException e) {
- e.printStackTrace();
- }
- if(choice == 1) {
- //create new artist
- String name;
- String title;
- //ask for name
- System.out.print("Please enter artist name: ");
- name = getInput();
- //print blank line
- System.out.println();
- //ask for title
- System.out.print("Please enter the track title: ");
- title = getInput();
- System.out.println("this is where we create an artist object with the name: " + name + " and title: " + title);
- //Artist artist = new Artist(name, title);
- } else if(choice == 2) {
- //create track
- //may need to keep a list of added artist objects in order to add an artist to a track
- } else if(choice == 3) {
- //create album
- //may need to keep a list of added artist objects in order to add an artist to a track
- } else if(choice == -1) {
- System.out.println("good bye");
- }
- }
- }
- public static String getInput() {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String input = null;
- try {
- input = reader.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return input;
- }
Add Comment
Please, Sign In to add comment