11 Replies - 525 Views - Last Post: 19 February 2012 - 04:21 AM Rate Topic: -----

#1 shahpur2004  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-February 12

Here are the code in the tag. this is my main.

Posted 18 February 2012 - 01:06 PM

[
#ifndef RANDOMWHEEL_H
#define RANDOMWHEEL_H

#include <vector>
#include <iostream>
using namespace std;

class RandomWheel
{
    private:
        int numberOfItems;
        int currentItem;
        vector<int> itemValues;
        vector<string> itemLabels;
    public:
        // CONSTRUCTOR
        RandomWheel(int itemCount, int values[], string labels[]);
        // MUTATORS
        void Spin();
        // ACCESSORS
        int GetCurrentValue() const;
        string GetCurrentLabel() const;
};

#endif // RANDOMWHEEL_H
]
here is my RandomWheel. cpp file
[#include "RandomWheel.h"
#include <cstdlib>
#include <ctime>

// CONSTRUCTOR
RandomWheel::RandomWheel(int itemCount, int values[], string labels[])
{
    srand(time(0));
    numberOfItems = itemCount;
    currentItem = 0;
    for (int i = 0; i < itemCount; i++)
    {
        itemValues.push_back(values[i]);
        itemLabels.push_back(labels[i]);
    }
}
// MUTATORS
void RandomWheel::Spin()
{
    currentItem = rand()%numberOfItems;
}
// ACCESSORS
int RandomWheel::GetCurrentValue() const
{
    return (itemValues[currentItem]);
}

string RandomWheel::GetCurrentLabel() const
{
    return (itemLabels[currentItem]);
}
]
Here is my main program
[#include <iostream>
#include "RandomWheel.h"
using namespace std;

int main()
{
    int numOfdice;
    int i = 0;
    string userinput;
    string lables[]= {"*", "&", "@", "%", "=|", "~>"};
    int values [] = { 1, 2, 3, 4, 5, 6 };


    vector <RandomWheel*> dicelist;
    cout <<"How many dice do you want to roll ";
    cin >> numOfdice;


    for (int i = 0; i < numOfdice; i++)
    {
        dicelist.push_back(new RandomWheel(6, values , lables));
    }
    for (int i = 0; i < numOfdice; i++)
    {
       dicelist[i]->Spin();
    }
     cout << "To play 'p' to quit 'q'";
    cin >> userinput;
    int count = 0;
    while(i < 5)
    {


        if (userinput =="p" )
        for (int i = 0; i < numOfdice; i++)
        {
            cout<< dicelist[i]->GetCurrentValue();
            

            for (int i = 0; i < dicelist.size(); i++)
        {
            count = dicelist[i]->GetCurrentValue();
            count++;

        }

        }


        if (userinput == "q")
        break;
        else
         cout << "\nTo play 'p' to quit 'q'";
        cin >> userinput;

    }

    cout<<"you total score is"<< count<<endl;

}

]
my question is how to set the game for five round, how to get the score of each round and how to re roll the particular die.

:code:

This post has been edited by jimblumberg: 18 February 2012 - 01:08 PM
Reason for edit:: Added missing Code Tags, Please learn to use them.


Is This A Good Question/Topic? 0
  • +

Replies To: Here are the code in the tag. this is my main.

#2 jimblumberg  Icon User is online

  • member icon


Reputation: 4232
  • View blog
  • Posts: 13,281
  • Joined: 25-December 09

Re: Here are the code in the tag. this is my main.

Posted 18 February 2012 - 01:09 PM

Please stop opening a new topic every time you try to fix your broken code tags.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6092
  • View blog
  • Posts: 23,612
  • Joined: 23-August 08

Re: Here are the code in the tag. this is my main.

Posted 18 February 2012 - 01:31 PM

Quote

my question is how to set the game for five round, how to get the score of each round and how to re roll the particular die.


So I'm guessing that's pretty much the entire assignment, huh?
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is online

  • member icon


Reputation: 4232
  • View blog
  • Posts: 13,281
  • Joined: 25-December 09

Re: Here are the code in the tag. this is my main.

Posted 18 February 2012 - 01:44 PM

Quote

my question is how to set the game for five round

What have you tried? We will not write this assignment for you, you must show reasonable effort to complete your assignment. The only effort you have shown so far is opening 5 different topics for this project. This is your assignment, get to work.


Jim
Was This Post Helpful? 0
  • +
  • -

#5 shahpur2004  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-February 12

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 12:06 AM

View Postjimblumberg, on 18 February 2012 - 01:44 PM, said:

Quote

my question is how to set the game for five round

What have you tried? We will not write this assignment for you, you must show reasonable effort to complete your assignment. The only effort you have shown so far is opening 5 different topics for this project. This is your assignment, get to work.


Jim

I do not want anyone to write me the code or do my assignment I only want some suggestions from you guys. How to set the game for five round, how to get the total score and how to re roll the a particular die. I made a for loop for the total but it does not give the right total which is this
[     for (int i = 0; i < dicelist.size(); i++)
        {
            count = dicelist[i]->GetCurrentValue();
            count++;

        }
cout<<"This is your total << count<<endl;
]

Was This Post Helpful? 0
  • +
  • -

#6 shahpur2004  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-February 12

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 12:12 AM

View Postjimblumberg, on 18 February 2012 - 01:09 PM, said:

Please stop opening a new topic every time you try to fix your broken code tags.

Jim

what are you talking about my codes are not broken, it is first time I am getting online help if you dont want to help me please dont say like this. That I am trying to fix my broken code tags.
Was This Post Helpful? 0
  • +
  • -

#7 shahpur2004  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-February 12

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 12:29 AM

View PostJackOfAllTrades, on 18 February 2012 - 01:31 PM, said:

Quote

my question is how to set the game for five round, how to get the score of each round and how to re roll the particular die.


So I'm guessing that's pretty much the entire assignment, huh?

what do you mean what I did is nothing if it is the entire assignment. I did not want anyone to do my assignment. I just wanted some suggestions. Instead of say like this you could give some suggestions. Anyway thank you for your reply.
Was This Post Helpful? 0
  • +
  • -

#8 Hezekiah  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 208
  • View blog
  • Posts: 552
  • Joined: 12-July 09

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 02:18 AM

Quote

my question is how to set the game for five round,

Try a for loop.

Quote

how to get the score of each round

count = dicelist[i]->GetCurrentValue();
count++;

That's the same as:
count = dicelist[i]->GetCurrentValue() + 1;


Quote

and how to re roll the particular die.

Isn't that what the Spin() function is for?
Was This Post Helpful? 0
  • +
  • -

#9 shahpur2004  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-February 12

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 02:40 AM

View PostHezekiah, on 19 February 2012 - 02:18 AM, said:

Quote

my question is how to set the game for five round,

Try a for loop.
where do you think I should try it.

Quote

how to get the score of each round

count = dicelist[i]->GetCurrentValue();
count++;

That's the same as:
count = dicelist[i]->GetCurrentValue() + 1;

yes it is, but it does not give the total score.

Quote

and how to re roll the particular die.

Isn't that what the Spin() function is for?

The spin() function is for randomly chose the die.
Was This Post Helpful? 0
  • +
  • -

#10 Hezekiah  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 208
  • View blog
  • Posts: 552
  • Joined: 12-July 09

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 03:16 AM

The Spin() function rolls the die. I wasn't exactly sure about your question.
Was This Post Helpful? 0
  • +
  • -

#11 shahpur2004  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 02-February 12

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 03:50 AM

View PostHezekiah, on 19 February 2012 - 03:16 AM, said:

The Spin() function rolls the die. I wasn't exactly sure about your question.


the question is how to re roll one or two of the rolled dice. for example the dice rolled 42651
how can i re roll 2 and 1 to improve my score.
Was This Post Helpful? 0
  • +
  • -

#12 Hezekiah  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 208
  • View blog
  • Posts: 552
  • Joined: 12-July 09

Re: Here are the code in the tag. this is my main.

Posted 19 February 2012 - 04:21 AM

View Postshahpur2004, on 19 February 2012 - 12:50 PM, said:

the question is how to re roll one or two of the rolled dice. for example the dice rolled 42651
how can i re roll 2 and 1 to improve my score.

You have to call Spin() on them again.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1