CSNoob
BAN USERWorks but I've only been programming for a little over a week so any advice would be helpful. :-)
static string HandOutcome(List<int> hand)
{
Dictionary<int, int> tmp = new Dictionary<int, int>();
List<string> found = new List<string>();
foreach (int i in hand)
{
if (!tmp.ContainsKey(i))
{
tmp.Add(i, 1);
}
else
{
int curValue = tmp[i] + 1;
tmp[i] = curValue;
}
}
foreach (int i in tmp.Values)
{
if (i == 4)
{
found.Add("four");
}
else if (i == 3){
found.Add("three");
}else if (i == 2)
{
found.Add("pair");
}
}
if (found.Contains("four"))
{
return "You have a 4 of a kind...";
}
else if (found.Contains("three") && found.Contains("pair"))
{
return "You have a full house";
}else if (found.Contains("three")) {
return "You have 3 of a kind";
}
else if (found.Contains("pair")){
found.Remove("pair");
if (found.Contains("pair"))
{
return "You have 2 pair!";
}
else
{
return "You have a pair..";
}
}
else
{
return "You have nothing...";
}
- CSNoob December 16, 2015
So sorry for the repeated. The site wasnt updating eariler and did think it was working. :-( not sure how to delete my last comments
- CSNoob December 16, 2015