zoukankan      html  css  js  c++  java
  • 排球比赛(记分员)迭代

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

    计划:估计此次工作需要长时间的努力。

    需求分析: 程序需要能做到每次分数变化的时候都要记录。 

    设计文档:

    1、排球比赛采用五局三胜制。前四局每局25分,每局比赛完成后交换场地,达到24分时,必须比赛的双方相差2分才能分出胜负;决胜局为15分,比赛的双方任何一方先达到8分时,交换场地继续比赛,当双方同时达到14分时候,也是必须相差两分才能决出胜负。

    2、每加一分,数据库中的数据+1,分数列表行+1。

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

    代码如下:(添加队伍,并在另一个页面能够看到参赛人员,以便于加分)

    //分数

    public class ScoreInfo
    {
    public ScoreInfo()
    {}
    string name;
    public string Name
    {
    get { return name; }
    set { name = value; }
    }
    int score;
    public int Score
    {
    get { return score; }
    set { score = value; }
    }
    string reason;
    public string Reason
    {
    get { return reason; }
    set { reason = value; }
    }

    public ScoreInfo(string name, int score, string reason)
    {
    this.name = name;
    this.score =score ;
    this.reason = reason;

    }
    }

    //队伍信息

    public class TeamInfo
    {
    public TeamInfo()
    {}
    string team;
    public string Team
    {
    get { return team; }
    set { team = value; }
    }
    string name;
    public string Name
    {
    get { return name; }
    set { name = value; }
    }
    int number;
    public int Number
    {
    get { return number; }
    set { number = value; }
    }

    public TeamInfo(string team, string name, int number)
    {
    this.team = team;
    this.name =name;
    this.number = number;

    }
    }

    //三层

    1、dal

    public int regist(TeamInfo team)
    {
    string strcom = "insert into Team(Team,Number,Name) values(@team,@number,@name);";
    SqlParameter[] pms = { new SqlParameter("@team",team.Team ), new SqlParameter("@number", team.Number), new SqlParameter("@name", team.Name)};
    return SqlHelper.ExecuteNonQuery(strcom, pms);
    }
    public bool updateScore(ScoreInfo score)
    {
    string strcom = "update Score set score=@score,reason=@reason where name=@name;";
    SqlParameter p = new SqlParameter("@name", score.Name);
    SqlParameter p1 = new SqlParameter("@score", score.Score);
    SqlParameter p2 = new SqlParameter("@reason", score.Reason);
    int i = SqlHelper.ExecuteNonQuery(strcom, p, p1, p2);
    return i > 0;
    }
    public List<ScoreInfo> search(string where)
    {
    string strcom = "select * from Score " + where;
    using (SqlDataReader dr = SqlHelper.ExecuteReader(strcom, null))
    {
    if (dr.HasRows)
    {
    List<ScoreInfo> students = new List<ScoreInfo>();
    while (dr.Read())
    {
    ScoreInfo student = new ScoreInfo(dr[0].ToString(),dr[1].GetHashCode(), dr[2].ToString());
    students.Add(student);
    }
    return students;
    }
    else
    { return null; }
    }
    }

    2、bll

    public bool updateStudent(ScoreInfo score)
    {
    return scoreinfo.updateScore(score);
    }
    public List<ScoreInfo> search(string where)
    {
    return scoreinfo.search(where);
    }
    public bool regist(TeamInfo stu)
    {
    return scoreinfo.regist(stu) > 0;
    }

    3、表现层

    a、html

    <form action="Team.ashx" method="post">
    请输入队名:
    <input name="txt_team" type="text" value="@team" id="team"/><br />
    <br />
    号&nbsp;&nbsp;&nbsp;码:<input name="txt_no" type="text" value="@no" id="no"/> 姓&nbsp;&nbsp;&nbsp;名:<input name="txt_name" type="text" value="@name" id="name"/><br /><br />
    号&nbsp;&nbsp;&nbsp;码:<input name="txt_no" type="text" value="@no" id="no"/>姓&nbsp;&nbsp;&nbsp;名:<input name="txt_name" type="text" value="@name" id="name"/><br /><br />
    号 &nbsp;&nbsp; 码:<input name="txt_no" type="text" value="@no" id="no"/>姓&nbsp;&nbsp;&nbsp;名:<input name="txt_name" type="text" value="@name" id="name"/><br /><br />
    号&nbsp;&nbsp;&nbsp;码:<input name="txt_no" type="text" value="@no" id="no"/> 姓&nbsp;&nbsp;&nbsp;名:<input name="txt_name" type="text" value="@name" id="name"/><br /><br />
    号&nbsp;&nbsp;&nbsp;码:<input name="txt_no" type="text" value="@no" id="no"/> 姓&nbsp;&nbsp;&nbsp;名:<input name="txt_name" type="text" value="@name" id="name"/><br /><br />
    号&nbsp;&nbsp;&nbsp;码:<input name="txt_no" type="text" value="@no" id="no"/> 姓&nbsp;&nbsp;&nbsp;名:<input name="txt_name" type="text" value="@name" id="name"/><br /><br />
    <input name="btn_China" type="submit" value="确定" />
    <br />
    <span>@msg</span>
    </form>

    b、ashx

    blic bll bll = new bll();
    public void ProcessRequest(HttpContext context)
    {
    context.Response.ContentType = "text/html";
    TeamInfo team = new TeamInfo();
    team.Team = context.Request.Form["txt_team"];
    team.Number=context.Request.Form["txt_no"].GetHashCode();
    team.Name = context.Request.Form["txt_name"];
    bool isOk = bll.regist(team);
    if (isOk)
    {
    string duiwu = context.Request.Form["txt_team"];
    string no = context.Request.Form["txt_no"];
    string name = context.Request.Form["txt_name"];
    HttpCookie cookies = new HttpCookie("Regist");
    cookies.Values.Add("Team", duiwu);
    cookies.Values.Add("No", no);
    cookies.Values.Add("Name", name);
    cookies.Expires = System.DateTime.Now.AddYears(1);
    HttpContext.Current.Response.Cookies.Add(cookies);
    context.Response.Cookies.Add(cookies);
    string path = context.Request.MapPath("Team.htm");
    string html = System.IO.File.ReadAllText(path);
    html = html.Replace("@msg", "另一支队伍");
    context.Response.Redirect("Play.aspx");
    }

    4、关于代码复审

    代码复审会在后面的代码编写中进行修改,尽量轻装上阵,减小内存。

  • 相关阅读:
    吴裕雄--天生自然JAVA开发JSP-SERVLET学习笔记:解决启动TOMCAT服务器乱码问题
    吴裕雄--天生自然JAVA开发JSP-SERVLET学习笔记:配置TOMCAT服务器
    吴裕雄--天生自然JAVA开发JSP-SERVLET学习笔记:修改服务器端口
    吴裕雄--天生自然JAVA开发JSP-SERVLET学习笔记:解决服务端口8080被占用的问题
    css 背景色渐变---和背景色透明
    nodePPT 这可能是迄今为止最好的网页版PPT
    正则表达式匹配
    WdatePicker.js 日历点击时,触发自定义方法 ,可以调用自己的函数。
    html 实时监控发送数据
    [转]使用onclick跳转到其他页面/跳转到指定url
  • 原文地址:https://www.cnblogs.com/150902yt/p/6568689.html
Copyright © 2011-2022 走看看