Friday, May 17, 2013

Just Need To Help Finishing This Up - C And C++ | Dream.In.Code


Example
#{example}
"); ipb.editor_values.get('templates')['togglesource'] = new Template("
??? Cancel Source Edit
"); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
  • Icon
  • "); ipb.editor_values.get('templates')['menu_item'] = new Template("
  • #{title}
  • "); ipb.editor_values.get('templates')['togglesource'] = new Template("
    ??? Cancel Source Edit
    "); ipb.editor_values.get('templates')['emoticons_showall'] = new Template(""); ipb.editor_values.get('templates')['emoticon_wrapper'] = 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]\n \n Test\n \n[/xml]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"member":{"id":"31","title":"Member","desc":"Given a member name, a link is automatically generated to the member's profile","tag":"member","useoption":"1","example":"[member=skyhawk133] runs this site.","switch_option":"0","menu_option_text":"Input Username of Member","menu_content_text":"","single_tag":"1","optional_option":"0","image":"memberbbcode.png"},"extract":{"id":"33","title":"Extract Blog Entry","desc":"This will allow users to define an extract for an entry. Only this piece of the entry will be displayed on the main blog page and will show up in the RSS feed.","tag":"extract","useoption":"0","example":"[extract]This is an example![/extract]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"blog":{"id":"34","title":"Blog Link","desc":"This tag provides an easy way to link to a blog.","tag":"blog","useoption":"1","example":"[blog=100]Click me![/blog]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"entry":{"id":"35","title":"Blog Entry Link","desc":"This tag provides an easy way to link to a blog entry.","tag":"entry","useoption":"1","example":"[entry=100]Click me![/entry]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"twitter":{"id":"36","title":"Twitter","desc":"A tag to link to a user's twitter account","tag":"twitter","useoption":"0","example":"[twitter]userName[/twitter]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"twitter.png"},"inline":{"id":"37","title":"Inline Code","desc":"Formats code inline instead of in a seperate code box. ","tag":"inline","useoption":"0","example":"[inline]style=\"font-size: 12px;\"[/inline]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"il":{"id":"38","title":"Abbreviated Inline (IL)","desc":"Abbreviated version of the [inline] tag. ","tag":"il","useoption":"0","example":"[il]Code Here[/il]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"il2.png"},"code":{"id":"41","title":"Code","desc":"Allows you to enter general code","tag":"code","useoption":"1","example":"[code]$text = 'Some long code here';[/code]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"1","image":""}}) ); ipb.vars['emoticon_url'] = "http://cdn.dreamincode.net/forums/public/style_emoticons/default"; //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = 15; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = 321115; //]]>

    6 Replies - 129 Views - Last Post: Yesterday, 07:18 AM Rate Topic: -----

    #1 helpmeeee ?Icon User is offline

    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 Skydiver ?Icon User is online

    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 helpmeeee ?Icon User is offline

    Reputation: 0

    • Posts: 6
    • Joined: 17-April 13

    Re: Just need to help finishing this up

    Posted Yesterday, 06:25 AM

    View PostSkydiver, on 15 May 2013 - 06:21 AM, said:

    So what is your question?


    I have an issue with the random generator.

    #4 ccubed ?Icon User is offline

    Reputation: 126

    • Posts: 1,297
    • Joined: 13-June 08

    Re: Just need to help finishing this up

    Posted Yesterday, 06:37 AM

    View Posthelpmeeee, on 15 May 2013 - 07:25 AM, said:

    View PostSkydiver, 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 JackOfAllTrades ?Icon User is online

    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 helpmeeee ?Icon User is offline

    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 JackOfAllTrades ?Icon User is online

    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.