ठीक है तो मैं एक पासा फेंक एप्लिकेशन है ...सी # कोड केवल चरण के माध्यम से अपेक्षित परिणाम देता है?
जब मैं कोड यह सामान्य रूप से काम करता है के माध्यम से कदम और 'परिणाम' फेंक परिणामों की सही संख्या में शामिल हैं और वे, यादृच्छिक होने के लिए जब मैं करने के लिए कोड छोड़ दिखाई दौड़ें और वही काम करें जो समान संख्याओं का एक सेट बनाता है।
मुझे यकीन है कि यह एक तार्किक त्रुटि है जिसे मैं नहीं देख सकता लेकिन घंटों के लिए इसके साथ झुकाव ने स्थिति में सुधार नहीं किया है, इसलिए किसी भी मदद की बहुत सराहना की जाती है। :)
class Dice
{
public int[] Roll(int _throws, int _sides, int _count)
{
Random rnd = new Random();
int[] results = new int[_throws];
// for each set of dice to throw pass data to calculate method
for (int i = 0; i < _throws; i++)
{
int thisThrow = Calculate(_sides, _count);
//add each throw to a new index of array... repeat for every throw
results[i] = thisThrow;
}
return results;
}
private int Calculate(int _sides, int _count)
{
Random rnd = new Random();
int[] result = new int[_count];
int total = 0;
//for each dice to throw put data into result
for (int i = 0; i < _count; i++)
{
result[i] = rnd.Next(1, _sides);
}
//count the values in result
for (int x = 0; x < _count; x++)
{
total = total + result[x];
}
//return total of all dice to Roll method
return total;
}
}
धन्यवाद अब संशोधित :) – Yoda
बहुत जल्दी ड्रा! –
@ इयान: मैंने देखा है कि यह अक्सर कई बार होता है न कि इसे तुरंत स्पॉट करें :) – leppie