• 实验五


    1.猫猫狗狗

     1 #include<string>
     2 using namespace std;
     3 #include<iostream> 
     4 #include"aa.h"
     5 
     6 class MachinePets{
     7     public:
     8         MachinePets(const string s):nickname(s){
     9         }
    10         string getNickname()const{
    11         return nickname;
    12         }
    13         virtual void talk()=0;
    14     private:
    15         string nickname;
    16 };
    17 
    18 class PetCats:public MachinePets{
    19     public:
    20         PetCats(const string s):MachinePets(s){
    21         }
    22         void talk(){
    23             cout<<getNickname()<<" says "<<endl;
    24             string s = "D:\myvideo\cat.wav\10652.wav";// "bt.wav";
    25             wchar_t wText[30] = { 0 };
    26             MByteToWChar(s.c_str(), wText, sizeof(wText) / sizeof(wText[0]));
    27             PlaySound(wText, NULL, SND_FILENAME | SND_SYNC);
    28 
    29         }
    30 };
    31 
    32 class PetDogs:public MachinePets{
    33     public:
    34         PetDogs(const string s):MachinePets(s){
    35         }
    36         void talk(){
    37             cout<<getNickname()<<" says "<<"ma"<<endl;
    38             string s = "D:\myvideo\dog.wav\1022.wav";// "bt.wav";
    39             wchar_t wText[30] = { 0 };
    40             MByteToWChar(s.c_str(), wText, sizeof(wText) / sizeof(wText[0]));
    41             PlaySound(wText, NULL, SND_FILENAME | SND_SYNC);
    42         }
    43 };
    44 
    45 void play(MachinePets *p) {
    46     p->talk();
    47 }
    48 
    49 int main(){
    50     PetCats cat("miku");
    51     PetDogs dog("da huang");
    52     
    53     play(&cat);
    54     play(&dog);
    55     
    56     return 0;
    57 }
    View Code
     1 #ifndef AA_H
     2 #define AA_H
     3 #include <Windows.h>
     4 #include <mmsystem.h>
     5 
     6 #include <iostream>
     7 #include <stdlib.h>
     8 #include <time.h>
     9 #include <assert.h>
    10 
    11 #pragma comment(lib,"WinMM.Lib")
    12 
    13 using namespace std;
    14 
    15 
    16 BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)
    17 {
    18     // Get the required size of the buffer that receives the Unicode 
    19     // string. 
    20     DWORD dwMinSize;
    21     dwMinSize = MultiByteToWideChar(CP_ACP, 0, lpcszStr, -1, NULL, 0);
    22     assert(dwSize >= dwMinSize);
    23 
    24     // Convert headers from ASCII to Unicode.
    25     MultiByteToWideChar(CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);
    26     return TRUE;
    27 }
    28 
    29 
    30 #endif
    aa.h

    2.

    (1)#ifndef _CONTAINER

    (2)numOfHeal--;

    (3) p.bag.set(0,0);   bag.set(p.bag.nOfHeal()+bag.nOfHeal(),p.bag.nOfMW()+bag.nOfHeal());

    (4)void showinfo(player &p1, player &p2)

    (5)public player

    (6)cout<<setw(50)<<"you lose"<<endl;

    (7)cout<<endl<<setw(50)<<"GAME OVER"<<endl;

    在写的过程中,查找音频花去了不少时间,还有就是小细节问题,容易导致程序运行出错。

    评论地址:

    https://www.cnblogs.com/shy0825/

    https://www.cnblogs.com/changtingzao/

    https://www.cnblogs.com/elise00/

  • 相关阅读:
    jfixed使固定行列可编辑表格
    Base 64 加密、解密
    去除富文本格式
    阿里移动安全挑战赛第二题研究小结
    CyanogenMod源码下载、编译、刷机过程记录(HTC buzz)
    编译民间安卓源码mokesoures4.2.2报错内容【解决了!】
    Linux下通过NDK的初步使用【详细步骤+截图】
    Linux下实现JNI期间发生的错误……【未解决】
    C++调用Java方法时jvm.dll相关错误 【每次记录完后都被瞬间解决了……】
    JNI学习中——JVM错误:EXCEPTION_ACCESS_VIOLATION (0xc0000005)
  • 原文地址:https://www.cnblogs.com/sqcmxg/p/10936738.html
Copyright © 2020-2023  润新知