monoteen

Digital Piano

Oct 7th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <conio.h>
  5. using namespace std;
  6. #pragma warning(default:4716)
  7.  
  8. class Music {
  9.  
  10. public:
  11.     int Snd[13];
  12.     int Sund_spd;
  13.  
  14.     Music(void)
  15.     {
  16.         Snd[0] = 262;
  17.         Snd[1] = 277;
  18.         Snd[2] = 294;
  19.         Snd[3] = 311;
  20.         Snd[4] = 330;
  21.         Snd[5] = 349;
  22.         Snd[6] = 370;
  23.         Snd[7] = 392;
  24.         Snd[8] = 415;
  25.         Snd[9] = 440;
  26.         Snd[10] = 466;
  27.         Snd[11] = 494;
  28.         Snd[12] = 523;
  29.  
  30.         Sund_spd = 150;
  31.     }
  32.  
  33.     char PianoGunban(void)
  34.     {
  35.  
  36.         int i = 1;
  37.  
  38.         while (i)
  39.         {
  40.             int n = getch();
  41.  
  42.             switch (n){
  43.             case 'A':
  44.             case 'a':
  45.                 Beep(Snd[0], Sund_spd);
  46.                 break;
  47.  
  48.             case 'w':
  49.             case 'W':
  50.                 Beep(Snd[1], Sund_spd);
  51.                 break;
  52.  
  53.             case 's':
  54.             case 'S':
  55.                 Beep(Snd[2], Sund_spd);
  56.                 break;
  57.  
  58.             case 'e':  
  59.             case 'E':
  60.                 Beep(Snd[3], Sund_spd);
  61.                 break;
  62.  
  63.             case 'D':
  64.             case 'd':
  65.                 Beep(Snd[4], Sund_spd);
  66.                 break;
  67.  
  68.             case 'F':
  69.             case 'f':
  70.                 Beep(Snd[5], Sund_spd);
  71.                 break;
  72.  
  73.             case 't':
  74.             case 'T':
  75.                 Beep(Snd[6], Sund_spd);
  76.                 break;
  77.  
  78.             case 'g':
  79.             case 'G':
  80.                 Beep(Snd[7], Sund_spd);
  81.                 break;
  82.  
  83.             case 'y':
  84.             case 'Y':
  85.                 Beep(Snd[8], Sund_spd);
  86.                 break;
  87.  
  88.             case 'h':
  89.             case 'H':
  90.                 Beep(Snd[9], Sund_spd);
  91.                 break;
  92.  
  93.             case 'U':
  94.             case 'u':
  95.                 Beep(Snd[10], Sund_spd);
  96.                 break;
  97.  
  98.             case 'j':
  99.             case 'J':
  100.                 Beep(Snd[11], Sund_spd);
  101.                 break;
  102.  
  103.             case 'K':
  104.             case 'k':
  105.                 Beep(Snd[12], Sund_spd);
  106.                 break;
  107.  
  108.             case 27:
  109.                 system("cls");
  110.                 i--;
  111.                 break;
  112.             }
  113.         }
  114.     }
  115.  
  116.     int Papper_Air(void)
  117.     {
  118.         Beep(Snd[3], Sund_spd);
  119.         Beep(Snd[2], Sund_spd);
  120.         Beep(Snd[1], Sund_spd);
  121.         Beep(Snd[2], Sund_spd);
  122.         Beep(Snd[3], Sund_spd);
  123.         Beep(Snd[3], Sund_spd);
  124.         Beep(Snd[3], Sund_spd);
  125.  
  126.         Sleep(200);
  127.         Beep(Snd[2], Sund_spd);
  128.         Beep(Snd[2], Sund_spd);
  129.         Beep(Snd[2], Sund_spd);
  130.  
  131.         Sleep(200);
  132.         Beep(Snd[3], Sund_spd);
  133.         Beep(Snd[3], Sund_spd);
  134.         Beep(Snd[3], Sund_spd);
  135.  
  136.         Sleep(200);
  137.         Beep(Snd[3], Sund_spd);
  138.         Beep(Snd[2], Sund_spd);
  139.         Beep(Snd[1], Sund_spd);
  140.         Beep(Snd[2], Sund_spd);
  141.         Beep(Snd[3], Sund_spd);
  142.         Beep(Snd[3], Sund_spd);
  143.         Beep(Snd[3], Sund_spd);
  144.  
  145.         Sleep(200);
  146.         Beep(Snd[2], Sund_spd);
  147.         Beep(Snd[2], Sund_spd);
  148.         Beep(Snd[3], Sund_spd);
  149.         Beep(Snd[2], Sund_spd);
  150.         Beep(Snd[1], Sund_spd);
  151.     }
  152. };
  153.  
  154.  
  155. class Menu{
  156.  
  157. private:
  158.     int Drow_Menu(void)
  159.     {
  160.         system("cls");
  161.         cout << endl << endl << endl << endl << endl << endl;
  162.         cout << "                        ┏━━━━━━━━━━━━★" << endl;
  163.         cout << "                        ┃ 디지털 피아노 프로그램 ┃" << endl;
  164.         cout << "                        ┗━━━━━━━━━━━━┛" << endl;
  165.         cout << endl << endl << endl << endl << endl << endl;
  166.         cout << "                             ┏━━━━━━━★" << endl;
  167.         cout << "                             ┃ 1. 연주 하기 ┃" << endl;
  168.         cout << "                             ┃ 2. 연주 듣기 ┃" << endl;
  169.         cout << "                             ┃              ┃" << endl;
  170.         cout << "                             ┃ 3. 나 가 기  ┃" << endl;
  171.         cout << "                             ┗━━━━━━━┛" << endl;
  172.     }
  173.  
  174.  
  175.     int Drow_Piano(void)
  176.     {
  177.         system("cls");
  178.         cout << " _____________________________________________________________________________★" << endl;
  179.         cout << "   1. 연주하기 " << endl;
  180.         cout << " _____________________________________________________________________________" << endl;
  181.         cout << endl;
  182.         cout << "    ━┳━┳━━┳┳━━┳━━┳━┳━━┳┳━━┳┳━━┳━━┳━━━┳━" << endl;
  183.         cout << "      ┃  ┃    ┃┃    ┃    ┃  ┃    ┃┃    ┃┃    ┃    ┃      ┃  " << endl;
  184.         cout << "      ┃  ┃    ┃┃    ┃    ┃  ┃    ┃┃    ┃┃    ┃    ┃      ┃  " << endl;
  185.         cout << "      ┃  ┃    ┃┃    ┃    ┃  ┃    ┃┃    ┃┃    ┃    ┃      ┃  " << endl;
  186.         cout << "      ┃  ┃    ┃┃    ┃    ┃  ┃    ┃┃    ┃┃    ┃    ┃      ┃  " << endl;
  187.         cout << "      ┃  ┃    ┃┃    ┃    ┃  ┃    ┃┃    ┃┃    ┃    ┃      ┃  " << endl;
  188.         cout << "      ┃  ┃도# ┃┃레# ┃    ┃  ┃파# ┃┃솔# ┃┃라# ┃    ┃      ┃  " << endl;
  189.         cout << "      ┃  ┃ w  ┃┃ e  ┃    ┃  ┃ t  ┃┃ y  ┃┃ u  ┃    ┃      ┃  " << endl;
  190.         cout << "      ┃  ┗━┳┛┗━┳┛    ┃  ┗━┳┛┗━┳┛┗━┳┛    ┃      ┃  " << endl;
  191.         cout << "      ┃      ┃      ┃      ┃      ┃      ┃      ┃      ┃      ┃  " << endl;
  192.         cout << "      ┃ [도] ┃ [레] ┃ [미] ┃ [파] ┃ [솔] ┃ [라] ┃ [시] ┃ [도] ┃  " << endl;
  193.         cout << "      ┃   a  ┃  s   ┃  d   ┃   f  ┃   g  ┃   h  ┃  j   ┃   k  ┃  " << endl;
  194.         cout << "    ━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━" << endl;
  195.         cout << " _____________________________________________________________________________" << endl;
  196.         cout << endl << endl << endl;
  197.         cout << " _____________________________________________________________________________" << endl;
  198.         cout << "                                                                 나가기 - ESC  " << endl;
  199.         cout << " _____________________________________________________________________________";
  200.     }
  201.  
  202.  
  203.     int Drow_Note(void)
  204.     {
  205.         system("cls");
  206.         cout << " __________________________________________________________________________★" << endl;
  207.         cout << "   2. 음악듣기 " << endl;
  208.         cout << " ____________________________________________________________________________" << endl;
  209.         cout << endl;
  210.         cout << "                                                                             " << endl;
  211.         cout << "                                   ******                                    " << endl;
  212.         cout << "                                   *******                                   " << endl;
  213.         cout << "                                   *********                                 " << endl;
  214.         cout << "                                   ****   ***                                " << endl;
  215.         cout << "                                   ****    ***                               " << endl;
  216.         cout << "                                   ****     ***                              " << endl;
  217.         cout << "                                   ****     ***                              " << endl;
  218.         cout << "                                   ****      **                              " << endl;
  219.         cout << "                                   ****      **                              " << endl;
  220.         cout << "                                *******                                      " << endl;
  221.         cout << "                              **********                                     " << endl;
  222.         cout << "                             ***********                                     " << endl;
  223.         cout << "                              *********                                      " << endl;
  224.         cout << "                               *******                                       " << endl;
  225.         cout << endl << endl;
  226.         cout << " ____________________________________________________________________________" << endl;
  227.         cout << "                                                                 나가기 - ESC  " << endl;
  228.         cout << " ____________________________________________________________________________";
  229.     }
  230.  
  231.  
  232. public:
  233.     int exit;
  234.  
  235.     int Main_Menu(void)
  236.     {
  237.         Drow_Menu();
  238.         char Menu_num = getch();
  239.         Music sound;
  240.  
  241.         switch (Menu_num)
  242.         {
  243.         case '1':
  244.             Drow_Piano();
  245.             sound.PianoGunban();
  246.             break;
  247.         case '2':
  248.             Drow_Note();
  249.             sound.Papper_Air();
  250.             getch();
  251.             break;
  252.         case '3':
  253.             exit = 0;
  254.             break;
  255.         }
  256.     }
  257.  
  258.  
  259. };
  260.  
  261. int main(void)
  262. {
  263.     Menu Call;
  264.     Call.exit = 1;
  265.  
  266.     while (Call.exit)
  267.     {
  268.         Call.Main_Menu();
  269.     }
  270.     return 0;
  271. }
Advertisement
Add Comment
Please, Sign In to add comment