Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 11th, 2007, 12:00 AM   #11
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
Well no matter which way I try to arrange them, it doesn't work. Does anyone know why it restarts when I type Yes? It starts repeating I think all the questions in the program without waiting for input.
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 11th, 2007, 1:00 AM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The first thing you need to do is show your new code. You can say you did this and that, but we are not sitting in your chair looking at your screen. The compiler is, but even the compiler doesn't like what you're doing.

I could also explain to you in detail why you need to test your input for success, but I've already done that about forty-leben times on this forum, and it gets old.

On another not, not important, does the scrambled case of your user name flag you as a 'hacker' to your friends? Just curious.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 11th, 2007, 2:42 AM   #13
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
Here is my new code, sorry for not posting it.

#include <iostream>
#include <string.h>
//Days of Legend. Programmed by Darin Beaudreau.
//Copyright© 2007-2012. All rights reserved.
//This code may not be redistributed.

using namespace std;

int main()
{
 while(1)
{
	string playername;
	string playerrace;
	string playerclass;
    int Yes = 1;
    int No = 2;
	int status;
	int ready;
	int menuchoice;

//Opening
cout << "\aHello there, what is your name? ";
getline (cin, playername);
cout << endl;
cout << "Hello, " << playername << "!\n";
cout << "\aWhat race will you play? ";
getline (cin, playerrace);
cout << "\aAnd what class shall you play, brave adventurer? ";
getline (cin, playerclass);
cout << "\aYou have chosen to be a " << playerrace << " " << playerclass << "!\n";
cout << "Welcome, " << playername << " to Days of Legend!\n";
cout << "\aIn a world filled with evil, will you take up your\n";
cout << "sword and defend the innocent? ";
cin >> ready;

	if (ready == Yes)
    {
		cout << "Then welcome to Narghoz, the first town in your\n";
		cout << "no doubt epic adventure!\n\n";
		cout << "What would you like to do, " << playername << "?\n";
		cout << "1.) Check Status\n";
		cout << "2.) Quit\n";
		cout << "Make your choice! ";
		cin >> menuchoice;
		}
	if (ready == No)
    {
		cout << "Then come back when you have some hair on your chest!\n";
		return 0;
    }
	}
 system ("PAUSE");
}

And yes, this is my alias on almost all the hacking forums I visit, including my own.
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 11th, 2007, 9:56 AM   #14
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You have a hacking forum? I don't know a single true hacker that can't write his or her own code.

Your user can not enter the value 1 or the value 2 unless your user knows all about how to press a key that will generate the appropriate control character. Your user will (you hope) enter '1' or '2', which is not the same thing. Even worse, what if the user enters 'zzzzzzzzzzzzzzzzzzz'. What will you do?

Will your game perform correctly if the user enters, as his or her race, "Bantu"? "Nagger"? Simply the ENTER key?

Go off and design your program before you code. Come back when you have some hair on your chest.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 11th, 2007, 11:04 AM   #15
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
First off, yes, I do have my own forum, but not everything related to hacking has to do with coding. The only coding related work I've done is with HTML, and Javascript.

Second, I asked for help, if you're not willing to help, then don't respond to my thread. I just started learning C++ this week so obviously I'm a noob at it, but who wasn't at one point?

And third, I have a website designed for the game because originally it wasn't going to be a video game. That website has a list of the races and classes so I don't think people would enter something other than what is given there.

So, sorry for being a noob, I guess I'm not welcome here.
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 11th, 2007, 11:09 AM   #16
Arnack
Programmer
 
Join Date: Jul 2005
Posts: 66
Rep Power: 4 Arnack is on a distinguished road
Yeah DaWei seems like he doesn't have much else to do but lay around on these forums rambling about how he is better than C++ than the newbies.
Sad, if you ask me.
Anyways, on topic:
What's your problem now?
__________________
Ack Network
*UNDER CONSTRUCTION*
Now hiring staff of all sorts.
Arnack is offline   Reply With Quote
Old Aug 11th, 2007, 5:08 PM   #17
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 4 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
Actually Dawei is right. He tells you straight up how it is. Bascially you need to experiment with your code and see how it behaves when you change.

If you are waiting for the user to enter a responce tell them what kind of a responce you are looking for.

For example:

Are you ready?
Enter (y,n) :

Then if the user enters y you can store that in a char and compare it to a 'y' or a 'n'

If you are planning on starting a game company then prepare yourself and your mate to listen to people like DaWei.

Good luck with the company:beard:
__________________
JG-Webdesign
Wizard1988 is offline   Reply With Quote
Old Aug 11th, 2007, 5:25 PM   #18
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
I HAVE experimented with the code, and mixed it around numerous times, but nothing I try works, which is why I asked for help.
PaCkEtPiRaTe is offline   Reply With Quote
Old Aug 11th, 2007, 6:47 PM   #19
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 93
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
http://www.cplusplus.com/doc/tutorial/

after cleaning up the code to make it make sense

C:\DOCUME~1\PEACEO~1\Desktop> g++ -o lol_at_this_game main.cpp
main.cpp:56:2: warning: no newline at end of file
C:\DOCUME~1\PEACEO~1\Desktop>lol_at_this_game.exe
Hello there, what is your name? pop

Hello, pop!
What race will you play? nagger
And what class shall you play, brave adventurer? bloodhound
You have chosen to be a nagger bloodhound!
Welcome, pop to Days of Legend!
In a world filled with evil, will you take up your
sword and defend the innocent? (Yes: 1, No: 2) 2
Then come back when you have some hair on your chest!

C:\DOCUME~1\PEACEO~1\Desktop>
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.

Last edited by peaceofpi; Aug 11th, 2007 at 7:00 PM.
peaceofpi is offline   Reply With Quote
Old Aug 11th, 2007, 10:10 PM   #20
PaCkEtPiRaTe
Newbie
 
Join Date: Aug 2007
Posts: 24
Rep Power: 0 PaCkEtPiRaTe is on a distinguished road
Ok now the program doesn't spaz out anymore when I enter yes, it just goes back to the beginning and asks me my name again.
PaCkEtPiRaTe is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is wrong with this code? c0ldshadow Visual Basic .NET 5 Dec 5th, 2005 5:37 PM
How to post a question nnxion C++ 10 Jun 3rd, 2005 11:53 AM
How to post a question nnxion C++ 0 Jun 3rd, 2005 8:55 AM
How to post a question nnxion C 0 Jun 3rd, 2005 8:55 AM
Any ideas what i've done wrong? (Newb C Programmer) Code included Ramlag C++ 10 Mar 22nd, 2005 1:57 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC