Advertisement
Sheero

NoteClientDemoClass

May 24th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.49 KB | None | 0 0
  1. //Zehra Baig
  2. //CSC-236-C1
  3. //Lab 2-B
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class NoteClientDemoClass
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner reader = new Scanner(System.in);
  12.         int noteValue;
  13.         String noteLength = "";
  14.         int selection = 0;
  15.        
  16.         while(selection != 6)
  17.         {
  18.             System.out.println("Default instantiation\n------------------------");
  19.            
  20.             System.out.println("Select a length for the note (type number): ");
  21.             System.out.println("1.) Whole Note\n2.) Half Note\n3.) Quarter Note"
  22.                              + "\n4.) Eighth Note\n5.) Sixteenth Note"
  23.                              + "\n6.) Use overloaded constructor instead");
  24.             selection = reader.nextInt();
  25.            
  26.             if(selection == 1)
  27.             {
  28.                 noteLength = "Whole Note";
  29.             }
  30.             else if(selection == 2)
  31.             {
  32.                 noteLength = "Half Note";
  33.             }
  34.             else if(selection == 3)
  35.             {
  36.                 noteLength = "Quarter Note";
  37.             }
  38.             else if(selection == 4)
  39.             {
  40.                 noteLength = "Eighth Note";
  41.             }
  42.             else if(selection == 5)
  43.             {
  44.                 noteLength = "Sixteenth Note";
  45.             }
  46.             else
  47.             {
  48.                 break;
  49.             }
  50.            
  51.             System.out.println("Enter numeric value of note (between -48 and 39): ");
  52.             noteValue = reader.nextInt();
  53.            
  54.             NoteDataStructureClass defNote = new NoteDataStructureClass();
  55.             defNote.setValue(noteValue);
  56.             defNote.setLength(noteLength);
  57.             System.out.println(defNote);
  58.         }
  59.        
  60.         selection = 0;
  61.         System.out.println();
  62.        
  63.         while(selection != 6)
  64.         {
  65.             System.out.println("Instantiation using overloaded constructor");
  66.             System.out.println("------------------------------------------");
  67.            
  68.             System.out.println("Select a length for the note (type number): ");
  69.             System.out.println("1.) Whole Note\n2.) Half Note\n3.) Quarter Note"
  70.                              + "\n4.) Eighth Note\n5.) Sixteenth Note\n6.) Exit");
  71.             selection = reader.nextInt();
  72.            
  73.             if(selection == 1)
  74.             {
  75.                 noteLength = "Whole Note";
  76.             }
  77.             else if(selection == 2)
  78.             {
  79.                 noteLength = "Half Note";
  80.             }
  81.             else if(selection == 3)
  82.             {
  83.                 noteLength = "Quarter Note";
  84.             }
  85.             else if(selection == 4)
  86.             {
  87.                 noteLength = "Eighth Note";
  88.             }
  89.             else if(selection == 5)
  90.             {
  91.                 noteLength = "Sixteenth Note";
  92.             }
  93.             else
  94.             {
  95.                 break;
  96.             }
  97.            
  98.             System.out.println("Enter numeric value of note (between -48 and 39): ");
  99.             noteValue = reader.nextInt();
  100.            
  101.             NoteDataStructureClass overNote = new NoteDataStructureClass(noteValue, noteLength);
  102.             System.out.println(overNote);
  103.         }
  104.        
  105.         System.out.println("Program exited.");
  106.         System.exit(0);
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement