首页 > 代码库 > 记分员计分程序

记分员计分程序

需求:作为一名现场记分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员及时掌握比赛状况。(满意条件:每一次比分的改变,都要形成一条记录)。

 

计划:估计此次工作需要一周的时间。

 

 

设计文档:

根据《2015-2016赛季中国排球联赛竞赛规程》,计分规则如下:

1、目前的排球比赛采用五局三胜制。前四局每局25分,每局比赛完成后交换场地,达到24分时,必须比赛的双方相差2分才能分出胜负;决胜局为15分,比赛的双方任何一方先达到8分时,交换场地继续比赛,当双方同时达到14分时候,也是必须相差两分才能决出胜负。
排球计分的发展历程:1917年规定每局为15分。1918年规定上场运动员每队为6人。1922年规定每方必须在3次以内将球击过网。比赛方法以前采用发球得分制,1998年10月28日国际排联决定改为每球得分制,仍为五局三胜,前四局每局先得25分者为胜,第五局先得15分者为胜,若出现24平或14平时,要继续比赛至某队领先2分才能取胜。

2、每点击一次按钮,分数列表就增加一行。

3、己方失误时。对方增加一分。

 

代码规范:使用C#语言标准、帕斯卡命名法和骆驼命名法 。

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>排球记分员</title>
    <style type="text/css">
     body
{
   
    }
#Mian table
{
    margin: 100px auto auto auto;
    text-align: center;
     color: Red;
     font-size:28px;
     font-family:微软雅黑 Light;
     width:1000px;
}
#TeamData table
{
    margin: 100px auto auto auto;
    text-align: center;
     color: Red;
     font-size:20px;
     font-family:微软雅黑 Light;
}
#TeamData table td{ width:240px;}
    </style>
    <script>
  var h=0;
  var t=0;
      function insRow(var1)
  {
      h=h+1;
  var n=document.getElementById(‘myTable‘).rows.length;
  console.log(n);
  var x=document.getElementById(‘myTable‘).insertRow(n);
  var y=x.insertCell(0);
  var z=x.insertCell(1);
  var v=x.insertCell(2);
  var f=x.insertCell(3);
  y.innerHTML="";
  z.innerHTML="";
  v.innerHTML=var1;
  f.innerHTML=h;
  }
 
    function addRow(var1)
  {
      t=t+1;
  var n=document.getElementById(‘myTable‘).rows.length;
  console.log(n);
  var x=document.getElementById(‘myTable‘).insertRow(n);
  var y=x.insertCell(0);
  var z=x.insertCell(1);
  var v=x.insertCell(2);
  var f=x.insertCell(3);
  v.innerHTML="";
  f.innerHTML="";
  y.innerHTML=var1;
  z.innerHTML=t;
  }
   function delRow()
   {
      var n=document.getElementById(‘myTable‘).rows.length-1;
      document.getElementById(‘myTable‘).deleteRow(n);
       }
    function Erra()
    {
        h=h+1;
         var n=document.getElementById(‘myTable‘).rows.length;
  var x=document.getElementById(‘myTable‘).insertRow(n);
  var y=x.insertCell(0);
  var z=x.insertCell(1);
  var v=x.insertCell(2);
  var f=x.insertCell(3);
  v.innerHTML="";
  f.innerHTML=h;
  y.innerHTML="";
  z.innerHTML="失误";
        }
 function Errb()
    {
        t=t+1;
         var n=document.getElementById(‘myTable‘).rows.length;
  var x=document.getElementById(‘myTable‘).insertRow(n);
  var y=x.insertCell(0);
  var z=x.insertCell(1);
  var v=x.insertCell(2);
  var f=x.insertCell(3);
  v.innerHTML="";
  f.innerHTML="失误";
  y.innerHTML="";
  z.innerHTML=t;
        }
    </script>
</head>
<body>   
<div id="Mian">
    <table id="sum"  border="0">
  <tbody>
    <tr>
      <td><input type="button" value="http://www.mamicode.com/2"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/9"  onClick="addRow(value)"></td>
      <td>中&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;国</td>
      <td>:</td>
      <td>塞尔维亚</td>
      <td><input type="button" value="http://www.mamicode.com/10"  onClick="insRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/19"  onClick="insRow(value)"></td>
    </tr>
     <tr>
      <td><input type="button" value="http://www.mamicode.com/12"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/10"  onClick="addRow(value)"></td>
       <td rowspan="3">03</td>
       <td rowspan="3">:</td>
       <td rowspan="3">04</td>
      <td><input type="button" value="http://www.mamicode.com/9"  onClick="insRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/6"  onClick="insRow(value)"></td>
    </tr>
     <tr>
      <td><input type="button" value="http://www.mamicode.com/1"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/17"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/16"  onClick="insRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/15"  onClick="insRow(value)"></td>
    </tr>
      <tr>
      <td><input type="button" value="http://www.mamicode.com/11"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/6"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/17"  onClick="insRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/3"  onClick="insRow(value)"></td>
    </tr>
     <tr>
      <td><input type="button" value="http://www.mamicode.com/3"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/7"  onClick="addRow(value)"></td>
      <td>0</td>
      <td>:</td>
      <td>0</td>
      <td><input type="button" value="http://www.mamicode.com/2"  onClick="insRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/8"  onClick="insRow(value)"></td>
    </tr>
     <tr>
      <td><input type="button" value="http://www.mamicode.com/16"  onClick="addRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/5"  onClick="addRow(value)"></td>
      <td><button  onClick="delRow()">误判减分</button>&nbsp;&nbsp;<input type="button" value="http://www.mamicode.com/失误"  onClick="Erra()"></td>
      <td></td>
      <td><button onClick="addRow()">误判减分</button>&nbsp;&nbsp;<input type="button" value="http://www.mamicode.com/失误"  onClick="Errb()"></td>
      <td><input type="button" value="http://www.mamicode.com/1"  onClick="insRow(value)"></td>
      <td><input type="button" value="http://www.mamicode.com/13"  onClick="insRow(value)"></td>
    </tr>
  </tbody>
</table>
</div>
<div id="TeamData">
<table id="myTable" border="1">
<tr><td colspan="2">A队</td><td colspan="2">B队</td></tr>
<tr><td>中国队员&nbsp;&nbsp;&nbsp;&nbsp;</td><td>累计得分</td><td>塞尔维亚队员</td><td>累计得分</td></tr>
</div>
</body>
</html>

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Moudel;
using VolleyballBll;

namespace VolleyballUI
{
    public partial class Main : System.Web.UI.Page
    {
        private  Game game = new Game();

        private GameBll gamebll = new GameBll();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TeamA.Text=Request.QueryString["TeamA"];
                TeamB.Text=Request.QueryString["TeamB"];
                Game game = new Game();
                game.TeamA = TeamA.Text;
                game.TeamB = TeamB.Text;
                if (gamebll.GetInsertGame(game))
                {
                     Response.Write("<script>alert(‘比赛开始!‘)</script>");
                }
            }
        }

        public void Add(string ab)
        {
            game.PsA = Convert.ToInt32( PsA.Text);
            game.PsB = Convert.ToInt32(PsB.Text);
            game.ScoreA = Convert.ToInt32(ScoreA.Text);
            game.ScoreB = Convert.ToInt32(ScoreB.Text);
            game.PartNum = game.PsA + game.PsB;
            if (ab == "a")
            {
                game.ScoreA += 1;
                ScoreA.Text = game.ScoreA.ToString();
                one();
                Victory();
            }
            else
            {
                game.ScoreB += 1;
                ScoreB.Text = game.ScoreB.ToString();
                one();
                Victory();
            }

        }

        protected void AddA_Click(object sender, EventArgs e)
        {
            string ab = "a";
            Add(ab);
        }

        protected void AddB_Click(object sender, EventArgs e)
        {
            string ab = "b";
            Add(ab);
        }

        public void one()
        {
            if (game.PartNum < 4)//前四局的加分计算和判断。
            {
                if (game.ScoreA >= 24 && game.ScoreB >= 24)//当两队24分平的情况。
                {
                    if (Math.Abs(game.ScoreA - game.ScoreB) == 2)
                    {
                        if (game.ScoreA > game.ScoreB)
                        {
                            game.PsA += 1;
                            PsA.Text = game.PsA.ToString();
                            game.ScoreA = 0;
                            ScoreA.Text = game.ScoreA.ToString();
                            game.ScoreB = 0;
                            ScoreB.Text = game.ScoreB.ToString();
                        }
                        else
                        {
                            game.PsB += 1;
                            PsB.Text = game.PsB.ToString();
                            game.ScoreA = 0;
                            ScoreA.Text = game.ScoreA.ToString();
                            game.ScoreB = 0;
                            ScoreB.Text = game.ScoreB.ToString();
                        }
                    }
                }
                else if(game.ScoreA<24||game.ScoreB<24) //当两队没有达到24分平的时候。
                {
                    if (game.ScoreA == 25)
                    {
                        game.PsA += 1;
                        PsA.Text = game.PsA.ToString();
                        game.ScoreA = 0;
                        ScoreA.Text = game.ScoreA.ToString();
                        game.ScoreB = 0;
                        ScoreB.Text = game.ScoreB.ToString();
                    }
                    else if (game.ScoreB == 25)
                    {
                        game.PsB += 1;
                        PsB.Text = game.PsB.ToString();
                        game.ScoreA = 0;
                        ScoreA.Text = game.ScoreA.ToString();
                        game.ScoreB = 0;
                        ScoreB.Text = game.ScoreB.ToString();
                    }
                }
            }
            else if (game.PartNum == 4)//第五局的加分计算和判断。
            {
                if (game.ScoreA >= 14 && game.ScoreB >= 14)//当两队24分平的情况。
                {
                    if (Math.Abs(game.ScoreA - game.ScoreB) == 2)
                    {
                        if (game.ScoreA > game.ScoreB)
                        {
                            game.PsA += 1;
                            PsA.Text = game.PsA.ToString();
                        }
                        else
                        {
                            game.PsB += 1;
                            PsB.Text = game.PsB.ToString();
                        }
                    }
                }
                else if (game.ScoreA < 14 || game.ScoreB < 14) //当两队没有达到24分平的时候。
                {
                    if (game.ScoreA == 15)
                    {
                        game.PsA += 1;
                        PsA.Text = game.PsA.ToString();
                    }
                    else if (game.ScoreB == 15)
                    {
                        game.PsB += 1;
                        PsB.Text = game.PsB.ToString();
                    }
                }
            }
            else
            {
                Response.Write("<script>alert(‘比赛已结束‘);</script>");
            }
        }

        public void Victory()
        {
            if (game.PsA==3||game.PsB==3)
            {
                game.ScoreA = 0;
                ScoreA.Text = game.ScoreA.ToString();
                game.ScoreB = 0;
                ScoreB.Text = game.ScoreB.ToString();
                AddA.Visible = false;
                AddB.Visible = false;
                Response.Write("<script>alert(‘比赛已结束‘);</script>");
            }
        }
    }
}

记分员计分程序