Example
#{example}"); ipb.editor_values.get('templates')['togglesource'] = new Template(""); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
Emoticons
"); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]6 Replies - 129 Views - Last Post: Yesterday, 07:18 AM
#1
Reputation: 0
- Posts: 6
- Joined: 17-April 13
Posted Yesterday, 06:10 AM
//hello #include <iostream> #include <string> #include <ctime> using namespace std; class Die { private: int value; public: int get_value(); void roll(); }; class Gambler { private: string name; int cash; public: int get_cash(); void set_cash(int amt); string get_name(); void set_name(string n); void add_cash(int amt); void sub_cash(int amt); }; //bool check_bet(Gambler g, int bet); void initGambler(Gambler & c, Die & d); int main() { void roll(); Gambler intro; Die Hi; initGambler(intro, Hi); } //Die int Die::get_value() { return value; } void Die::roll() { int value; srand (time(NULL)); value = rand() % 6 +1; return; } //Gambler int Gambler::get_cash() { return cash; } void Gambler::set_cash(int amt) { cash = amt; } string Gambler::get_name() { return name; } void Gambler::set_name(string n) { name = n; } //void Gambler::add_cash(int amt) //{ // //} //void Gambler::sub_cash(int amt) //{ // //} // //bool check_bet(Gambler g, int bet) //{ //} void initGambler(Gambler & c, Die & d) { d.roll(); string Name; int mula, bet, die1, die2, total, total_2; char answer; void roll(); /*total = d.roll() + d.roll();*/ cout << "\nWelcome, What is your name?: "; cin >> Name; c.set_name(Name); cout << "\nOk, " << Name << " how much cash do you have today?: "; cin >> mula; c.set_cash(mula); cout << "\nLet's play!"<< endl; while(true) { cout << "\n**** NEW GAME! **** " << endl; cout << "You are starting with " << c.get_cash() << endl; cout << "What is your starting bet? "; cin >> bet; Die die1; die1.get_value(); cout << "Your initial rolls were: " << die1.get_value() << "and " << d.get_value() << "for a total of " /*<< total*/; if (total == 2 || total == 3 || total == 8) { cout << "You win!"; /*cash = cash + bet;*/ cout << "You are up $" << bet << " and have $" << c.get_cash() << endl; cout << "\nWould you like to play again? "; cin >> answer; if(answer == 'Y' || 'y') { continue; } else { exit(0); } } else if (total == 7 || total == 11) { cout << "\n Sorry you lose!"<< endl; cout << "\n Would you like to play again?(Y/N?): "; cin >> answer; if(answer == 'Y' || answer == 'y') { continue; } else if(answer == 'N' || answer == 'n') { cout << "\n Thanks for playing!" << endl; exit(0); } } else { do { cout << "\n Would you like to (r)oll again or (b)et? "; cin >> answer; if(answer == 'b' || answer == 'B') { cout << "\n Please enter your bet: "; //cin >> bet; //if(bet <= c.get_cash()) //{ // bet = bet + new_bet; //} //else //{ // cout << "\n Invalid number!"; // bet = 0; //} cout << "\n Your bet is up to $" << bet; } else if(answer == 'r' || answer == 'R') { cout << "\n New Roll is: " << d.get_value() << " and " << d.get_value() << " for a total of " << total_2 << "." << endl; if (total == total_2) { cout << "\n I'm sorry you lose. Better luck next time." << endl; /*cash = cash - money;*/ /*c.sub_cash(cash);*/ cout << "\n You are down $" << bet << " and have $" << c.get_cash() << endl; cout << "\n\n Would you like to play again? "; cin >> answer; if(answer == 'y' || answer == 'Y') { continue; } else if(answer == 'n' || answer == 'N') { exit(0); } } else if (total_2 == 11) { cout << "\n You win!!!!" << endl; } else { cout << "\n Roll again! " << endl; } cout << "Would you like to play again?"; cin >> answer; } }while(answer == 'Y' || answer == 'y'); } } }
Is This A Good Question/Topic? 0
Replies To: Just need to help finishing this up
#2
Reputation: 1886
- Posts: 5,657
- Joined: 05-May 12
Re: Just need to help finishing this up
Posted Yesterday, 06:21 AM
So what is your question?
#3
Reputation: 0
- Posts: 6
- Joined: 17-April 13
Re: Just need to help finishing this up
Posted Yesterday, 06:25 AM
Skydiver, on 15 May 2013 - 06:21 AM, said:
So what is your question?
I have an issue with the random generator.
#4
Reputation: 126
- Posts: 1,297
- Joined: 13-June 08
Re: Just need to help finishing this up
Posted Yesterday, 06:37 AM
helpmeeee, on 15 May 2013 - 07:25 AM, said:
Skydiver, on 15 May 2013 - 06:21 AM, said:
So what is your question?
I have an issue with the random generator.
That issue being?
#5
Reputation: 5658
- Posts: 22,500
- Joined: 23-August 08
Re: Just need to help finishing this up
Posted Yesterday, 06:41 AM
You reported your post saying you posted the wrong code. If that's the case, then post the right code.srand(time(NULL)) should be called ONCE, at the very start of your program, in main.
#6
Reputation: 0
- Posts: 6
- Joined: 17-April 13
Re: Just need to help finishing this up
Posted Yesterday, 06:44 AM
For some reason it won't print out the correct random numbers from one to six. It prints out a number like -8888872222, I was wondering what I could use in line 122 to prevent that.I do not want you to finish my code, I just want to know what is going on with the random gen
#7
Reputation: 5658
- Posts: 22,500
- Joined: 23-August 08
Re: Just need to help finishing this up
Posted Yesterday, 07:18 AM
Honestly, looking at this code, there are a LOT of problems. Your problem is you're getting the value of a die you haven't rolled, but even if you did roll it, the value would be wrong because the variable you're setting in your function to roll a die is local to the function, not the member variable of the Die class.
Page 1 of 1
Source: http://www.dreamincode.net/forums/topic/321115-just-need-to-help-finishing-this-up/
redskins sugar bowl downton abbey season 3 2013 Calendar chris christie sofia vergara American Horror Story
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.