code help

Reply

Join Date: May 2005
Posts: 5
Reputation: t3bruce is an unknown quantity at this point 
Solved Threads: 0
t3bruce t3bruce is offline Offline
Newbie Poster

code help

 
0
  #1
May 19th, 2005
  1. using dice std;
  2. # include <cstdlib>
  3.  
  4.  
  5. int dice( )
  6.  
  7. {
  8. int. random_ interger = rand ( )
  9. cout << random_ interger << end 1
  10. }
<< moderator edit: added [code][/code] tags >>


. Write the member function definitions for each function listed:

1. Object Type: a pair of dice
Knows:
The value of each face (1 – 6)
Can Do:
Roll for new face values
Tell the value on each face.

Initialize the die to have a value of 1 on each face. To roll the die, use the rand() function, to generate a random number. In order to generate a random number between 1 and 6, use the following:
Number = rand() % 6 + 1;
rand() is located in <cstdlib>
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: code help

 
0
  #2
May 19th, 2005
As much as I want to help you, it looks like you want someone else to do your work for you. The code you've provided doesn't even come close to an attempt to solve the problem. It's asking you to write a Dice class that supports rolling the dice and giving the result. If you're having trouble with C++ at the fundamental level as your code suggests, you really need personal, face to face help instead of the clipped "this is your problem, here's how to fix it" help that you'd get here.

And no, nobody is going to write this for you.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,319
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 230
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: code help

 
0
  #3
May 19th, 2005
Originally Posted by t3bruce
  1. using dice std;
  2. # include <cstdlib>
  3.  
  4.  
  5. int dice( )
  6.  
  7. {
  8. int. random_ interger = rand ( )
  9. cout << random_ interger << end 1
  10. }
<< moderator edit: added [code][/code] tags >>


. Write the member function definitions for each function listed:

1. Object Type: a pair of dice
Knows:
The value of each face (1 – 6)
Can Do:
Roll for new face values
Tell the value on each face.

Initialize the die to have a value of 1 on each face. To roll the die, use the rand() function, to generate a random number. In order to generate a random number between 1 and 6, use the following:
Number = rand() % 6 + 1;
rand() is located in <cstdlib>
Is there a question there? My first answer is to back up a couple pages in your text and reread the stuff about basic syntax.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC