public bool PK(PKCountry A, PKCountry B, PKCountry W) { double Aall = GetSum(A, W); double Ball = GetSum(B, W); return(Aall > Ball); }
private void button1_Click(object sender, EventArgs e) { try { PKCountry A = new PKCountry(); A.Skill = Convert.ToDouble(skill1.Text); A.People = Convert.ToDouble(people1.Text); A.Science = Convert.ToDouble(science1.Text); A.Money = Convert.ToDouble(money1.Text); PKCountry B = new PKCountry(); B.Skill = Convert.ToDouble(skill2.Text); B.People = Convert.ToDouble(people2.Text); B.Science = Convert.ToDouble(science2.Text); B.Money = Convert.ToDouble(money2.Text); PKCountry W = new PKCountry(); W.Skill = Convert.ToDouble(skillNUD.Value); W.People = Convert.ToDouble(peopleNUD.Value); W.Science = Convert.ToDouble(scienceNUD.Value); W.Money = Convert.ToDouble(moneyNUD.Value); MessageBox.Show(PK(A, B, W) ? "甲胜利" : "乙胜利"); } catch { MessageBox.Show("UNKNOWN ERROR"); } }
public double GetSum(PKCountry i, PKCountry W) { return(i.Skill * W.Skill + i.People * W.People + i.Science * W.Science + i.Money * W.Science); }