I'm New Here :D

Hello guys, i am IceZaur97.
I am new here in this forum, so yeah....
Since i'm new here, i think i ought to release a program i made...
It's a probability game i made when i was bored, so here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <windows.h>
#include <cstdlib>

using namespace std;

int wimp(){
system("CLS");
cout << "That should not be your choice!\n";
cout << "Please Turn up your volume to the highest. please,\n";
while (1 == 1){
cout << "THIS IS YOUR PUNISHMENT\n\a";
}
}

int main()
{
	game:
	string name;
	int doorn;
	int chance;
	string yn;
	string choice;

    cout << "Welcome Everyone To This Wonderful Gameshow!\n";
    cout << "I am your host, Q.A.I, better known as Quantum artificial intelligense and here we we have our fine contestant...\n";
    cout << "psst\nWhat's your name again?";
    cin >> name;
    cout << '\n';
    cout << name << '!' << '\n' << endl;
    cout << "Now, This Is A Very Simple Game. There Are Three Doors In Which You Must Choose From. first_door, second_door And Last But Not Least, third_door. One Of Them Has A MILLION DOLLARS In Which You Can Win And The Other Two Have A Goat Behind Them. Now Choose Your Door For The Crowd Is Waiting...\n";
    pick:
    cout << "please input either 1 for the first door, 2 for the second, and 3 for third:\n ";
    cin >> doorn;
    switch(doorn){
		case 1:
		chance = rand()%3;
		break;
		case 2:
		chance = rand()%3;
		break;
		case 3:
		chance = rand()%3;
		break;
		default:
		wimp();
		break;
    }
    cout << name << " has chose door number " << doorn << "!\n\n";
    cout << '\a' << "Now I Will Reveal A Door With A Goat Behind It And You Will Be Given A Choice To Change Your Mind Or Stay With Your Decision\n";
	cout << "I'm Opening Door number " << doorn << " And...\nThere Is A Goat Behind It!!!\n";
	cout << "Now You May Choose To Change Your Mind Or Not. Its Your Choice " << name << ".\n\nPlease input either change or stay:";
	cin >> choice;
	if (choice == "change"){
	goto pick;
	}
	else if (choice == "stay");
	else
	{
		wimp();
	}
	cout << "\nFinally Ladies And Gentlemen, We Will See If " << name << " Has Chosen The Correct Door. I Will Open " << name << "'s Door And If Its Correct " << name << " Goes Away With ONE MILLION Dollars!!!\n\n";
	rollagain:
	chance = rand()%3;
	if (chance == 0){
		goto rollagain;
	}
	if (chance == doorn){
		cout << "\nI Have Opened Door Number " << doorn << " And " << name << " Has Won One MILLION DOLLARS!!!\n\a\a\a\a\a\a\a\a\a\a";
	}
	else
	{
		cout << "I Have Opened Door Number " << doorn << " And " << name << " Has Won A Goat! The Correct Door Was door number " << chance << "!!!!\n";
	}
	cout << "And Thats It For This Round Folks!\nDo you wish to start all over?";
	cin >> yn;
	if (yn == "yes"){
		system("CLS");
	goto game;
	}
	else if (yn == "no"){
		system("CLS");
		cout << "Hasta luegos who ever you are (I suck at spanish :D)...\n";
		cout << "This game was brought to you by: \n" << "+=Marvin=+, without him, all has fallen!\n";
	}
	else
	{
		wimp();
	}
    return 0;
}


If you are too lazy to compile, here's the binary:
Executable: http://www.mediafire.com/?gqn9c2b00nz78dt

I'm not exactly a C++ wiz, but i know how to use it.
Never really too C++ seriously.
You can suggest some programs that you want me to make if you want, but not too advance :D.

P.S. If you know some alternative to system("CLS");, please comment :D
closed account (3hM2Nwbp)
Hi there. You might want to read up on the use of the goto directive. In this particular case, it won't do any damage, but as you get deeper into larger object oriented applications, it can have severe side-affects if misused (that may not appear right away!)

There are quite a few articles written by some of the more qualified members of the board here. Feel free to read them; and welcome!
So....
In that case, it's fine to use the 'goto' command.
I've never really gotten to using other alternatives,
But if i have no choice, then i would just use the while, for and do loops :D
Maybe i should concentrate on it.
goto should be a last resort. ALWAYS prefer control structures such as for(), while(), and do-while().
Ok, thanks!
I'll use the loops on my next project. but not on this one,
Ok, but I recommend a bottle of aspirin to get you through this one.
What do you meant by that?
He's probably referring to the \a's, or the abnormal usage of goto in c++ code, either way it's a headache =)

Oh I have a program for you to write, if you're interested.
Definitely a referral to the use of the goto statement :P. Next we'll learn it was developed in DevC++ or Borland C++ =\
I love the term 'write only' code. Of course, we've all heard of the term 'read only' - referring for example to a file with the read only bit set; or a quantity typed as const. Source code with piles of gotos jumping around to various targets - spaggitti code - is 'write only'. In a fit of inspiration, lucid thinking, or luck, you might get it to work. Only thing is, you'll never be able to successfully modify it in the slightest without redoing the whole mess from scratch. Its 'write only'.
Last edited on
In a fit of inspiration, lucid thinking, or luck, you might get it to work. Only thing is, you'll never be able to successfully modify it in the slightest without redoing the whole mess from scratch. Its 'write only'.


That is one of the coolest things I've heard in a while.
Topic archived. No new replies allowed.