# 求算法!(急),该如何处理(2)

www.myexceptions.net  网友分享于：2013-03-13  浏览：4次

int tmp = 0;
if (vMethodInfo != null)
{
tmp = (int)vMethodInfo.Invoke(this, new object[] { favor, (Largess)Enum.Parse(typeof(Largess), largess) });
}
ret[largess] = tmp;
}

return ret;
}

private int LargessCalc(FavorFirstChoice favor, Largess largess)
{
string methodName = largess.ToString() + "Largess ";
MethodInfo vMethodInfo = this.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
if (vMethodInfo != null)
{
return (int)vMethodInfo.Invoke(this, new object[] { favor });
}
else return 0;
}

private int DLargess(FavorFirstChoice favor)
{
int ret = 0;
int tmpA = 0;
int tmpB = 0;
if (_goods.ContainsKey( "A ")) tmpA = _goods[ "A "];
if (_goods.ContainsKey( "B ")) tmpB = _goods[ "B "];

if (favor == FavorFirstChoice.A)
{
while (tmpA > 1)
{
ret++;
tmpA -= 2;
}
tmpB += tmpA;
while (tmpB > 1)
{
ret++;
tmpB -= 2;
}
}
else if (favor == FavorFirstChoice.B)
{
while (tmpB > 1)
{
ret++;
tmpA -= 2;
}
tmpA += tmpB;
while (tmpA > 1)
{
ret++;
tmpA -= 2;
}
}

_goods[ "A "] = tmpA;
_goods[ "B "] = tmpB;

return ret;
}

private int ELargess(FavorFirstChoice favor)
{
int ret = 0;
int tmp = 0;
if (_goods.ContainsKey( "B "))
{
tmp = _goods[ "B "];
while (tmp > 1)
{
ret++;
tmp -= 2;
}
}

_goods[ "B "] = tmp;
return ret;
}

private int FLargess(FavorFirstChoice favor)
{
int ret = 0;
int tmp = 0;
if (_goods.ContainsKey( "C "))
{
tmp = _goods[ "C "];
while (tmp > 1)
{
ret++;
tmp -= 2;
}
}

_goods[ "C "] = tmp;
return ret;
}