Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.util.HashMap;
  2.  
  3. public class BlackOrWhiteKey {
  4.     public static String blackOrWhiteKey(int keyPressCount) {
  5.         HashMap<Integer, String> keynotesColor = new HashMap<Integer, String>();
  6.        
  7.        
  8.         keynotesColor.put(1, "white");
  9.         keynotesColor.put(2, "black");
  10.         int a = 0;
  11.         int b = 3;
  12.         while (a < 7) {
  13.         keynotesColor.put(b, "white");
  14.         b++;
  15.         keynotesColor.put(b, "white");
  16.         b++;
  17.         keynotesColor.put(b, "black");
  18.         b++;
  19.         keynotesColor.put(b, "white");
  20.         b++;
  21.         keynotesColor.put(b, "black");
  22.         b++;
  23.         keynotesColor.put(b, "white");
  24.         b++;
  25.         keynotesColor.put(b, "white");
  26.         b++;
  27.         keynotesColor.put(b, "black");
  28.         b++;
  29.         keynotesColor.put(b, "white");
  30.         b++;
  31.         keynotesColor.put(b, "black");
  32.         b++;
  33.         keynotesColor.put(b, "white");
  34.         b++;
  35.         keynotesColor.put(b, "black");
  36.         b++;
  37.         a++;
  38.         }
  39.         keynotesColor.put(b, "white");
  40.         keynotesColor.put(b+1, "white");
  41.        
  42.         while (keyPressCount>88) {
  43.             keyPressCount -= 88;
  44.         }
  45.        
  46.         return keynotesColor.get(keyPressCount);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement