<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Roulette Spiel]]></title><description><![CDATA[<p>Hallo,</p>
<p>irgendwie scheint mein Roulette Spiel nicht so zu wollen, wie ich. Entweder es wird tatsächlich immer die gleiche Zufallszahl in dem Array abgespeichert oder ich greife immer auf die gleiche Zahl zu. Lieder seh ich den Fehler nicht -.-</p>
<p>Roulette.h</p>
<pre><code class="language-cpp">class Roulette
{
	public:
		Roulette();
		Roulette(int numberOfGames);
		~Roulette();
		int playOneGame();
		void playRotation();
		void printRotation();
		void sortRotation();
		int differentInRotation();
		long getNumberofRotations();

	private:
		static const int ARRAY_SIZE = 37;
		int rotation[ARRAY_SIZE];
		long numberOfRotations;
};
</code></pre>
<p>Roulette.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &quot;Roulette.h&quot;
using namespace std;

Roulette::Roulette(int numberOfGames)
{
	numberOfRotations =0;
	for (int i =1; i&lt;=numberOfGames; i++)
	{
		playRotation();
		printRotation();
	}
}

Roulette::~Roulette()
{
	cout &lt;&lt; numberOfRotations &lt;&lt; endl;
}

int Roulette::playOneGame()
{
	srand(time(0));
	int winnerOfGame=0;
	winnerOfGame= rand()%37;

	return winnerOfGame;
}

void Roulette::playRotation()
{
	for (int i=0; i&lt;=36; i++)
	{
		rotation[i] = playOneGame();
	}
	++numberOfRotations;
}

void Roulette::printRotation()
{
	cout &lt;&lt; &quot;Rotaion: &quot; &lt;&lt; numberOfRotations &lt;&lt; endl &lt;&lt; endl;
	for (int i =0; i&lt;=36; i++)
	{
		cout &lt;&lt; &quot;Die &quot; &lt;&lt; i+1 &lt;&lt; &quot;ausgepielte Zahl ist eine &quot; &lt;&lt; rotation[i] &lt;&lt;endl;
	}
	cout &lt;&lt;  endl &lt;&lt; endl;
}
</code></pre>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &quot;Roulette.h&quot;
using namespace std;

int main()
{
	Roulette myGame(5);

	system(&quot;PAUSE&quot;);

	return 0;
}
</code></pre>
<p>ist der seed für den Rand an der falschen Stelle, oder lese ich eventuell falsch aus, doer was?</p>
<p>P.S fü+r die die Sich wundern, eine Rotation, soll genau aus 37 einzelnen Spielen bestehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206920/roulette-spiel</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 16:45:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206920.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Mar 2008 16:30:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Roulette Spiel on Sat, 01 Mar 2008 16:31:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>irgendwie scheint mein Roulette Spiel nicht so zu wollen, wie ich. Entweder es wird tatsächlich immer die gleiche Zufallszahl in dem Array abgespeichert oder ich greife immer auf die gleiche Zahl zu. Lieder seh ich den Fehler nicht -.-</p>
<p>Roulette.h</p>
<pre><code class="language-cpp">class Roulette
{
	public:
		Roulette();
		Roulette(int numberOfGames);
		~Roulette();
		int playOneGame();
		void playRotation();
		void printRotation();
		void sortRotation();
		int differentInRotation();
		long getNumberofRotations();

	private:
		static const int ARRAY_SIZE = 37;
		int rotation[ARRAY_SIZE];
		long numberOfRotations;
};
</code></pre>
<p>Roulette.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &quot;Roulette.h&quot;
using namespace std;

Roulette::Roulette(int numberOfGames)
{
	numberOfRotations =0;
	for (int i =1; i&lt;=numberOfGames; i++)
	{
		playRotation();
		printRotation();
	}
}

Roulette::~Roulette()
{
	cout &lt;&lt; numberOfRotations &lt;&lt; endl;
}

int Roulette::playOneGame()
{
	srand(time(0));
	int winnerOfGame=0;
	winnerOfGame= rand()%37;

	return winnerOfGame;
}

void Roulette::playRotation()
{
	for (int i=0; i&lt;=36; i++)
	{
		rotation[i] = playOneGame();
	}
	++numberOfRotations;
}

void Roulette::printRotation()
{
	cout &lt;&lt; &quot;Rotaion: &quot; &lt;&lt; numberOfRotations &lt;&lt; endl &lt;&lt; endl;
	for (int i =0; i&lt;=36; i++)
	{
		cout &lt;&lt; &quot;Die &quot; &lt;&lt; i+1 &lt;&lt; &quot;ausgepielte Zahl ist eine &quot; &lt;&lt; rotation[i] &lt;&lt;endl;
	}
	cout &lt;&lt;  endl &lt;&lt; endl;
}
</code></pre>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &quot;Roulette.h&quot;
using namespace std;

int main()
{
	Roulette myGame(5);

	system(&quot;PAUSE&quot;);

	return 0;
}
</code></pre>
<p>ist der seed für den Rand an der falschen Stelle, oder lese ich eventuell falsch aus, doer was?</p>
<p>P.S fü+r die die Sich wundern, eine Rotation, soll genau aus 37 einzelnen Spielen bestehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1466159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1466159</guid><dc:creator><![CDATA[ThaRealMatix]]></dc:creator><pubDate>Sat, 01 Mar 2008 16:31:53 GMT</pubDate></item><item><title><![CDATA[Reply to Roulette Spiel on Sat, 01 Mar 2008 16:41:25 GMT]]></title><description><![CDATA[<p>pack mal srand in den Konstruktor, damit die funktion nur einmal gerufen wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1466164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1466164</guid><dc:creator><![CDATA[elise]]></dc:creator><pubDate>Sat, 01 Mar 2008 16:41:25 GMT</pubDate></item><item><title><![CDATA[Reply to Roulette Spiel on Sat, 01 Mar 2008 16:42:41 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-172876.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-172876.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1466166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1466166</guid><dc:creator><![CDATA[Coastguard]]></dc:creator><pubDate>Sat, 01 Mar 2008 16:42:41 GMT</pubDate></item></channel></rss>