University of design practice open class programming homework, World of Warcraft: Preparing for

Source: Internet
Author: User

The first version of World of Warcraft, preparing for it. relatively simple.

Because I took this class, the course has been open to the eighth week, these assignments have not been submitted. So the code is not submitted through OJ judgment, need attention. If someone later handed in this code, there is no AC, hope to be able to tell the next. (also, here I want to be familiar with the next VS environment, so the code is written in VS2013, before committing may need to comment out #include "stdafx.h", and the main function of the parameter table and function name may need to be modified under. )

Welcome to the reference, you are welcome to ask questions.

Code:

w3-Programming Jobs-World of Warcraft 1-Preparing for the Cpp:defines the entry point for the console application.//#include "stdafx.h" #include <iostream& gt; #include <string>using std::cin;using std::string;using std::cout;using std::endl;//using namespace Std;int Wlf[5];//dragon, Ninja, Iceman, Lion, Wolf's initial health value string Wrname[5] = {"Dragon", "Ninja", "Iceman", "Lion", "Wolf"};class Hea Dq{int lifen;//Life element int wno;//Samurai Maximum number int WORRIOR[5];//5 Samurai number of orders string Name;bool stop;//whether to stop manufacturing Samurai PUBLIC:HEADQ (int lfn = 0, String SNM = ""): Lifen (LFN), WNO (0), name (SNM), stop (0) {memset (worrior,0,sizeof (Worrior));} BOOL Gen_wr (int time, int k)//Generate Samurai {if (Lifen < wlf[k]) with number k {return false;} Wno++;worrior[k]++;lifen = Lifen-wlf[k];cout.fill (' 0 ');//Set padding character, always valid cout.width (3);//Set field width to 3, one effective cout << time << "" << name << "<<wrname[k]<<" "<< Wno <<" born with Strength "<< Wlf[k] << "," << Worrior[k] << "" << Wrname[k] << "in" << name << "hEadquarter "<< endl;//here has been in the output name times wrong, because there is no #include<string>. I directly using std::string, unexpectedly can also declare stringreturn true;} BOOL Is_stop (int time) {BOOL flag = 0;//flag can continue to manufacture samurai for (int i = 0; i < 5; ++i) {if (Lifen >= wlf[i]) {flag = 1; Brea K }//as long as you can also make a samurai}if (flag = = 0) {Cout.fill (' 0 ');//Set the fill character, always valid cout.width (3);//Set the field width to 3, a valid cout << time << "" << name << "Headquarter stops making warriors" << endl;stop = True;return true;} return false;} BOOL Getstopflag (void) {return stop;}}; int _tmain (int argc, _tchar* argv[]) {int n;cin >> n;for (int i = 1; I <= n;++i) {cout << "case:" << I << endl;int m;cin >> m;cin >> wlf[0] >> wlf[1] >> wlf[2] >> wlf[3] >> wlf[4]; HEADQ REDHQ (M, "red");//Red Side Press Iceman, Lion, Wolf, Ninja, Dragon Order: 2,3,4,1,0HEADQ Bluehq (M, "blue");//Blue Side by Lion, Dragon, Ninja  , Iceman, Wolf Order: 3,0,1,2,4int redsx[5] = {2,3,4,1,0};int Bluesx[5] = {3, 0, 1, 2, 4};int time = 0;int REDK = 0;int Bluek = 0;while (REDHQ. Getstopflag () = = False | | Bluehq.getstopflag () = = False) {while (Redhq.getstopflag () ==false && redhq.is_stop (time) ==false && REDHQ.GEN_WR (time, redsx[redk]) = = false)//When the Samurai is not stopped and the build samurai fails, the next spawn warrior {redk = (redk + 1)% 5 is generated;} REDK = (redk + 1)% 5;while (Bluehq.getstopflag () ==false && bluehq.is_stop (time) ==false && BLUEHQ.GEN_WR ( Time, Bluesx[bluek]) = = false)//When the Samurai build is not stopped and the Spawn samurai fails, the next spawn warrior {Bluek = (Bluek + 1)% 5 is generated;} Bluek = (Bluek + 1)% 5;time++;}} return 0;}


University of design practice open class programming homework, World of Warcraft: Preparing for

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.