-
Oct 31st, 2010, 03:47 AM
#1
Thread Starter
New Member
If Else Code snippit
This is a snippit for my program that has a bunch of monster descriptions. And all that stuff. It is for runescape. So check it out.
What it does, it get's a value stores it into the string, checks for the if... if not than it says so, gets value again. Loops to the top, and of course works.
Im new to c++, so please dont expect it to be the best thing in the world. I coded it on my own, so its not the best but works. If there is a better method for this, than please let me know.
Code:
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
string monster;
cout << "Welcome to monster master. \n";
Sleep(5000);
loop:
system("CLS");
cout << "Monster name: ";
getline(cin,monster);
if (monster == "Black Dragon"){
cout << "High Defence dragon. 199 slayer xp per kill. \n";
Sleep(5000);}
else if (monster == "Fire Giants"){
cout << "Easy monster. 111 slayer xp per kill. \n";
Sleep(5000);}
else if (monster == "List"){
cout << " \n";
cout << "Black Dragon \n";
cout << "Fire Giants \n";
Sleep(20000);}
else if (monster == "Exit"){
cout << " \n";
exit(0);}
else{
cout << "Please retry.";
Sleep(5000);}
goto loop;
cin.get();
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|