1.计划时间
一星期左右
2.需求分析
用户故事:作为一个赛事管理人员,我希望知道每场比赛队伍得分和积分情况,以便给每队进行排名。
3.生成设计文档
用来统计每个队伍的比分和积分情况,以便进行排名。
4.设计复审
将编写的程序进行生成,进行设计复审。看看是否生成错误,如果错误进行修改。
5.代码规范:
利用VS对该程序进行代码规范。
6.具体设计:
规则:排球比赛采用五局三胜制。前四局每局25分,谁先得到25分获胜,第五局为15分,先获得15分获胜。
若打成3比1或3比0胜队积3分,负队积0分打成3比2胜队积2分,负队积1分。
代码:
namespace 排球积分程序
{
public partial class Form1 : Form
{
Action action = new Action();
int i = 1;
StringBuilder sb = new StringBuilder();
public void INSERT()
{
Model M = new Model();
M.IDA = textBox1.Text.Trim().ToString();
M.IDB = textBox2.Text.Trim().ToString();
M.ONE = txtCount1.Text.Trim().Substring(4, 4);
M.TWO = txtCount2.Text.Trim().Substring(4, 4);
M.THREE = txtCount3.Text.Trim().Substring(4, 4);
if (txtCount4.Text =="")
{
M.FOUR = null;
}
else
{
M.FOUR = txtCount4.Text.Trim().Substring(4, 4);
}
if (txtCount5.Text =="")
{
M.FIVE= null;
}
else
{
M.FIVE = txtCount5.Text.Trim().Substring(4, 4);
}
M.SUM = txtH1.Text.ToString() + ":" + txtL1.Text.ToString();
M.Detail = sb.ToString();
action.InsertPK(M);
}
public int SELECT(string Name)
{
string sql = "select Grade from paiming where Name=@Name";
SqlParameter pms = new SqlParameter("@Name",Name);
return (int)SqlHelper.ExecuteScalar(sql,pms);
}
public void UPDATE(string Name,int Grade)
{
string sql = "update paiming set Grade=@Grade where Name=@Name";
SqlParameter[] pms = { new SqlParameter("@Grade",Grade),
new SqlParameter("Name",Name)};
int count = SqlHelper.ExecuteNonQuery(sql,pms);
}
private void btnH_Click(object sender, EventArgs e)
{
int H = Convert.ToInt32(txtH.Text);
int L = Convert.ToInt32(txtL.Text);
int H1 = Convert.ToInt32(txtH1.Text);
int L1 = Convert.ToInt32(txtL1.Text);
txtH.Text = (H+1).ToString();
sb.AppendFormat("第{0}个球 {1}:{2}\r\n",H+1,H+1,L);
if (H >= 24 && (H - L) > 0)
{
txtH1.Text = (Convert.ToInt32(txtH1.Text) + 1).ToString();
if((H1+L1)==0){
txtCount1.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 1)
{
txtCount2.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 2)
{
txtCount3.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 3)
{
txtCount4.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";
if (txtH1.Text == "3")
{
MessageBox.Show(textBox1.Text+"胜利");
INSERT();
int fen = SELECT(textBox1.Text);
int fen2 = SELECT(textBox2.Text);
if (int.Parse(txtH1.Text) == 3 && int.Parse(txtL1.Text) == 0)
{
UPDATE(textBox1.Text, fen + 3);
}
if (int.Parse(txtH1.Text) == 3 && int.Parse(txtL1.Text) == 1)
{
UPDATE(textBox1.Text, fen + 3);
}
if (int.Parse(txtH1.Text) == 3 && int.Parse(txtL1.Text) == 2)
{
UPDATE(textBox1.Text, fen + 2);
UPDATE(textBox2.Text, fen2 + 1);
}
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
}
}
if (H1 + L1 > 3)
{
if (H >= 14 && (H - L) > 1)
{
txtH1.Text = (Convert.ToInt32(txtH1.Text) + 1).ToString();
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text + "\r\n";
}
txtH.Text = "0";
txtL.Text = "0";
if (txtH1.Text == "3")
{
MessageBox.Show(textBox1.Text + "胜利");
INSERT();
int fen = SELECT(textBox1.Text);
int fen2 = SELECT(textBox2.Text);
if (int.Parse(txtH1.Text) == 3 && int.Parse(txtL1.Text) == 0)
{
UPDATE(textBox1.Text, fen + 3);
}
if (int.Parse(txtH1.Text) == 3 && int.Parse(txtL1.Text) == 1)
{
UPDATE(textBox1.Text, fen + 3);
}
if (int.Parse(txtH1.Text) == 3 && int.Parse(txtL1.Text) == 2)
{
UPDATE(textBox1.Text, fen + 2);
UPDATE(textBox2.Text, fen2 + 1);
}
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
i = 1;
}
}
}
}
private void btnL_Click(object sender, EventArgs e)
{
int H = Convert.ToInt32(txtH.Text);
int L = Convert.ToInt32(txtL.Text);
int H1 = Convert.ToInt32(txtH1.Text);
int L1 = Convert.ToInt32(txtL1.Text);
txtL.Text = (L+1).ToString();
sb.AppendFormat("第{0}个球 {1}:{2}\r\n", L + 1, H, L+1);
if (L>= 24&&(L-H )>0)
{
txtL1.Text = (Convert.ToInt32(txtL1.Text) + 1).ToString();
if((H1+L1)==0){
txtCount1.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
} if ((H1 + L1) == 1)
{
txtCount2.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 2)
{
txtCount3.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 3)
{
txtCount4.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";
if (txtL1.Text=="3")
{
MessageBox.Show(textBox2.Text + "胜利");
INSERT();
int fen = SELECT(textBox2.Text);
int fen2 = SELECT(textBox1.Text);
if (int.Parse(txtL1.Text) == 3 && int.Parse(txtH1.Text) == 0)
{
UPDATE(textBox2.Text, fen + 3);
}
if (int.Parse(txtL1.Text) == 3 && int.Parse(txtH1.Text) == 1)
{
UPDATE(textBox2.Text, fen + 3);
}
if (int.Parse(txtL1.Text) == 3 && int.Parse(txtH1.Text) == 2)
{
UPDATE(textBox2.Text, fen + 2);
UPDATE(textBox1.Text, fen2 + 1);
}
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
}
}
if(H1+L1>3)
{
if (L >= 14 && (L - H) > 1)
{
txtL1.Text = (Convert.ToInt32(txtL1.Text) + 1).ToString();
if((H1+L1)==4){
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";
if (txtL1.Text == "3")
{
MessageBox.Show(textBox2.Text + "胜利");
INSERT();
int fen = SELECT(textBox2.Text);
if (int.Parse(txtL1.Text) == 3 && int.Parse(txtH1.Text) == 0)
{
UPDATE(textBox2.Text, fen + 3);
}
if (int.Parse(txtL1.Text) == 3 && int.Parse(txtH1.Text) == 1)
{
UPDATE(textBox2.Text, fen + 3);
}
if (int.Parse(txtL1.Text) == 3 && int.Parse(txtH1.Text) == 2)
{
UPDATE(textBox2.Text, fen + 2);
UPDATE(textBox1.Text, fen + 1);
}
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
i = 1;
}
}
}
}
private void btnH1_Click(object sender, EventArgs e)
{
if (int.Parse(txtH.Text) > 0)
{
txtH.Text = (Convert.ToInt32(txtH.Text) - 1).ToString();
}
}
private void btnL1_Click(object sender, EventArgs e)
{
if (int.Parse(txtH.Text) > 0)
{
txtL.Text = (Convert.ToInt32(txtL.Text) - 1).ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
paiming p = new paiming();
p.Show();
}
8、代码复审:
经过复审修改完善了部分代码
9、测试:
基本功能测试成功
10、总结:这次的冲刺让我深刻体会到了自己编程方面的薄弱,特别是代码刚开始无从下手,经过同学的帮助才能完成,我要充分利用这个假期,补习补习,提高编程的能力。
原文:http://www.cnblogs.com/zh1997/p/6257655.html