zoukankan      html  css  js  c++  java
  • 第一小组作业

    • 计划

            估计此程序需要5-6天。

    • 开发
    • 需求分析

             作为一名现场记分员,我希望详细记录比赛现场比分增长情况,以便观众及运动员、教练员及时掌握比赛状况。(满意条件:精确到每一局的具体比分增长情况)。

              从分析用例故事可以知道完成此程序需要这两项任务:选择队伍和记录比赛分数

              以下为改程序的活动图:

    • 代码规范:使用Vs2010和帕斯卡命名法和骆驼命名法 。
    • 具体设计:

                 以下为程序的类图:

     

    • 具体编码

                 以下为部分代码:

             

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Web;
     5 using System.Web.UI;
     6 using System.Web.UI.WebControls;
     7 using VolleyballBll;
     8 using Moudel;
     9 
    10 namespace VolleyballUI
    11 {
    12     public partial class Index : System.Web.UI.Page
    13     {
    14         private TeamBll teamBll = new TeamBll();
    15 
    16         protected void Page_Load(object sender, EventArgs e)
    17         {
    18             if (!IsPostBack)
    19             {
    20                 BindDropDownList();
    21             }
    22         }
    23 
    24         protected void btnSaveName_Click(object sender, EventArgs e)
    25         {
    26             Team team = new Team();
    27              team.Name=TeamName.Text.Trim();
    28              if (teamBll.GetInsertTeamName(team))
    29              {
    30                  Response.Redirect("Index.aspx");
    31              }
    32              else
    33              {
    34                  Response.Write("<script>alert('添加失败')</script>");
    35              }
    36         }
    37 
    38         public void BindDropDownList()
    39         {
    40             DropDownListA.DataSource = teamBll.GetSelectAllTeams();
    41             DropDownListA.DataTextField = "Name";
    42             DropDownListA.DataValueField = "ID";
    43             DropDownListA.DataBind();
    44             DropDownListB.DataSource = teamBll.GetSelectAllTeams();
    45             DropDownListB.DataTextField = "Name";
    46             DropDownListB.DataValueField = "ID";
    47             DropDownListB.DataBind();
    48         }
    49 
    50         protected void btnSave_Click(object sender, EventArgs e)
    51         {
    52             if (DropDownListA.SelectedItem.Text == DropDownListB.SelectedItem.Text)
    53             {
    54                 Response.Write("<script>alert('同一支队伍之间不能比赛!')</script>");
    55             }
    56             else
    57             {
    58                 Response.Redirect("Main.aspx?TeamA=" + DropDownListA.SelectedItem.Text + "&TeamB=" + DropDownListB.SelectedItem.Text);
    59             }
    60         }
    61 
    62         protected void btnSelect_Click(object sender, EventArgs e)
    63         {
    64             if (DropDownListA.SelectedItem.Text == DropDownListB.SelectedItem.Text)
    65             {
    66                 Response.Write("<script>alert('同一支队伍之间没有比赛!')</script>");
    67             }
    68             else
    69             {
    70                 Response.Redirect("Select.aspx?TeamA=" + DropDownListA.SelectedItem.Text + "&TeamB=" + DropDownListB.SelectedItem.Text);
    71             }
    72         }
    73     }
    74 }

     

      1 using System;
      2 using System.Collections.Generic;
      3 using System.Linq;
      4 using System.Web;
      5 using System.Web.UI;
      6 using System.Web.UI.WebControls;
      7 using Moudel;
      8 using VolleyballBll;
      9 
     10 namespace VolleyballUI
     11 {
     12     public partial class Main : System.Web.UI.Page
     13     { 
     14         private  Game game = new Game();
     15 
     16         private GameBll gamebll = new GameBll();
     17 
     18         protected void Page_Load(object sender, EventArgs e)
     19         {
     20             if (!IsPostBack)
     21             {
     22                 TeamA.Text=Request.QueryString["TeamA"];
     23                 TeamB.Text=Request.QueryString["TeamB"];
     24                 Game game = new Game();
     25                 game.TeamA = TeamA.Text;
     26                 game.TeamB = TeamB.Text;
     27                 if (gamebll.GetInsertGame(game))
     28                 {
     29                      Response.Write("<script>alert('比赛开始!')</script>");
     30                 }
     31             }
     32         }
     33 
     34         public void Add(string ab)
     35         {
     36             game.PsA = Convert.ToInt32( PsA.Text);
     37             game.PsB = Convert.ToInt32(PsB.Text);
     38             game.ScoreA = Convert.ToInt32(ScoreA.Text);
     39             game.ScoreB = Convert.ToInt32(ScoreB.Text);
     40             game.PartNum = game.PsA + game.PsB;
     41             if (ab == "a")
     42             {
     43                 game.ScoreA += 1;
     44                 ScoreA.Text = game.ScoreA.ToString();
     45                 one();
     46                 Victory();
     47             }
     48             else 
     49             {
     50                 game.ScoreB += 1;
     51                 ScoreB.Text = game.ScoreB.ToString();
     52                 one();
     53                 Victory();
     54             }
     55 
     56         }
     57 
     58         protected void AddA_Click(object sender, EventArgs e)
     59         {
     60             string ab = "a";
     61             Add(ab);
     62         }
     63 
     64         protected void AddB_Click(object sender, EventArgs e)
     65         {
     66             string ab = "b";
     67             Add(ab);
     68         }
     69 
     70         public void one()
     71         {
     72             if (game.PartNum < 4)//前四局的加分计算和判断。
     73             {
     74                 if (game.ScoreA >= 24 && game.ScoreB >= 24)//当两队24分平的情况。
     75                 {
     76                     if (Math.Abs(game.ScoreA - game.ScoreB) == 2)
     77                     {
     78                         if (game.ScoreA > game.ScoreB)
     79                         {
     80                             game.PsA += 1;
     81                             PsA.Text = game.PsA.ToString();
     82                             game.ScoreA = 0;
     83                             ScoreA.Text = game.ScoreA.ToString();
     84                             game.ScoreB = 0;
     85                             ScoreB.Text = game.ScoreB.ToString();
     86                         }
     87                         else
     88                         {
     89                             game.PsB += 1;
     90                             PsB.Text = game.PsB.ToString();
     91                             game.ScoreA = 0;
     92                             ScoreA.Text = game.ScoreA.ToString();
     93                             game.ScoreB = 0;
     94                             ScoreB.Text = game.ScoreB.ToString();
     95                         }
     96                     }
     97                 }
     98                 else if(game.ScoreA<24||game.ScoreB<24) //当两队没有达到24分平的时候。
     99                 {
    100                     if (game.ScoreA == 25)
    101                     {
    102                         game.PsA += 1;
    103                         PsA.Text = game.PsA.ToString();
    104                         game.ScoreA = 0;
    105                         ScoreA.Text = game.ScoreA.ToString();
    106                         game.ScoreB = 0;
    107                         ScoreB.Text = game.ScoreB.ToString();
    108                     }
    109                     else if (game.ScoreB == 25)
    110                     {
    111                         game.PsB += 1;
    112                         PsB.Text = game.PsB.ToString();
    113                         game.ScoreA = 0;
    114                         ScoreA.Text = game.ScoreA.ToString();
    115                         game.ScoreB = 0;
    116                         ScoreB.Text = game.ScoreB.ToString();
    117                     }
    118                 }
    119             }
    120             else if (game.PartNum == 4)//第五局的加分计算和判断。
    121             {
    122                 if (game.ScoreA >= 14 && game.ScoreB >= 14)//当两队24分平的情况。
    123                 {
    124                     if (Math.Abs(game.ScoreA - game.ScoreB) == 2)
    125                     {
    126                         if (game.ScoreA > game.ScoreB)
    127                         {
    128                             game.PsA += 1;
    129                             PsA.Text = game.PsA.ToString();
    130                         }
    131                         else
    132                         {
    133                             game.PsB += 1;
    134                             PsB.Text = game.PsB.ToString();
    135                         }
    136                     }
    137                 }
    138                 else if (game.ScoreA < 14 || game.ScoreB < 14) //当两队没有达到24分平的时候。
    139                 {
    140                     if (game.ScoreA == 15)
    141                     {
    142                         game.PsA += 1;
    143                         PsA.Text = game.PsA.ToString();
    144                     }
    145                     else if (game.ScoreB == 15)
    146                     {
    147                         game.PsB += 1;
    148                         PsB.Text = game.PsB.ToString();
    149                     }
    150                 }
    151             }
    152             else
    153             {
    154                 Response.Write("<script>alert('比赛已结束');</script>");
    155             }
    156         }
    157 
    158         public void Victory()
    159         {
    160             if (game.PsA==3||game.PsB==3)
    161             {
    162                 game.ScoreA = 0;
    163                 ScoreA.Text = game.ScoreA.ToString();
    164                 game.ScoreB = 0;
    165                 ScoreB.Text = game.ScoreB.ToString();
    166                 AddA.Visible = false;
    167                 AddB.Visible = false;
    168                 Response.Write("<script>alert('比赛已结束');</script>");
    169             }
    170         }
    171     }
    172 }

     以下为选择队伍进入比赛的界面:

             

    以下为查询后的界面:

     

    关于代码复审,测试和之后的报告,会在接下来的几天时间内完成并逐渐完善自己的程序。

  • 相关阅读:
    数据量你造吗-JAVA分页
    编写高质量代码改善java程序的151个建议——[1-3]基础?亦是基础
    概率论快速学习03:概率公理补充
    概率论快速学习02:概率公理
    项目ITP(六) spring4.0 整合 Quartz 实现动态任务调度
    项目ITP(五) spring4.0 整合 Quartz 实现任务调度
    编写高质量代码改善java程序的151个建议——导航开篇
    概率论快速学习01:计数
    改善JAVA代码01:考虑静态工厂方法代替构造器
    Python快速学习10: 循环的对象及设计 (生活的规律)
  • 原文地址:https://www.cnblogs.com/DD-1202B/p/6218585.html
Copyright © 2011-2022 走看看