Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zehra Baig
- //CSC-236-C1
- //Lab 2-B
- import java.util.Scanner;
- public class NoteClientDemoClass
- {
- public static void main(String[] args)
- {
- Scanner reader = new Scanner(System.in);
- int noteValue;
- String noteLength = "";
- int selection = 0;
- while(selection != 6)
- {
- System.out.println("Default instantiation\n------------------------");
- System.out.println("Select a length for the note (type number): ");
- System.out.println("1.) Whole Note\n2.) Half Note\n3.) Quarter Note"
- + "\n4.) Eighth Note\n5.) Sixteenth Note"
- + "\n6.) Use overloaded constructor instead");
- selection = reader.nextInt();
- if(selection == 1)
- {
- noteLength = "Whole Note";
- }
- else if(selection == 2)
- {
- noteLength = "Half Note";
- }
- else if(selection == 3)
- {
- noteLength = "Quarter Note";
- }
- else if(selection == 4)
- {
- noteLength = "Eighth Note";
- }
- else if(selection == 5)
- {
- noteLength = "Sixteenth Note";
- }
- else
- {
- break;
- }
- System.out.println("Enter numeric value of note (between -48 and 39): ");
- noteValue = reader.nextInt();
- NoteDataStructureClass defNote = new NoteDataStructureClass();
- defNote.setValue(noteValue);
- defNote.setLength(noteLength);
- System.out.println(defNote);
- }
- selection = 0;
- System.out.println();
- while(selection != 6)
- {
- System.out.println("Instantiation using overloaded constructor");
- System.out.println("------------------------------------------");
- System.out.println("Select a length for the note (type number): ");
- System.out.println("1.) Whole Note\n2.) Half Note\n3.) Quarter Note"
- + "\n4.) Eighth Note\n5.) Sixteenth Note\n6.) Exit");
- selection = reader.nextInt();
- if(selection == 1)
- {
- noteLength = "Whole Note";
- }
- else if(selection == 2)
- {
- noteLength = "Half Note";
- }
- else if(selection == 3)
- {
- noteLength = "Quarter Note";
- }
- else if(selection == 4)
- {
- noteLength = "Eighth Note";
- }
- else if(selection == 5)
- {
- noteLength = "Sixteenth Note";
- }
- else
- {
- break;
- }
- System.out.println("Enter numeric value of note (between -48 and 39): ");
- noteValue = reader.nextInt();
- NoteDataStructureClass overNote = new NoteDataStructureClass(noteValue, noteLength);
- System.out.println(overNote);
- }
- System.out.println("Program exited.");
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement