944,212 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1386
  • C++ RSS
May 19th, 2005
0

code help

Expand Post »
C++ Syntax (Toggle Plain Text)
  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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
t3bruce is offline Offline
5 posts
since May 2005
May 19th, 2005
0

Re: code help

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.
Reputation Points: 35
Solved Threads: 3
Posting Whiz in Training
Dogtree is offline Offline
232 posts
since May 2005
May 19th, 2005
0

Re: code help

Quote originally posted by t3bruce ...
C++ Syntax (Toggle Plain Text)
  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.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Defining structure for a scenarios
Next Thread in C++ Forum Timeline: c++ help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC