排球现场计分员三层架构版

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

每次比分改变将数据库里面的内容随之改变。

计划

估算时间

实际时间

估计这个任务需要多少时间

300min

600min

开发

200min

500min

需求分析

10min

10min

生成设计文档

20min

20min

设计复审

10min

20min

代码规范

10min

10min

具体设计

20min

40min

具体编码

120min

300min

代码复审

10min

100min

测试

100min

100min

测试报告

50min

50min

计算工作量

20min

20min

事后总结并提出改进计划

30min

30min

设计数据库

四个数据库 一个存储A队球员的信息。一个存储B队球员的信息。

一个存储A队球员的得分情况,另一个存储B队球员的得分情况。

设计案例如下:

首先显示界面让其填入球员名单。

记分员根据现场情况来实现加分减分。

A失误给B加分

B失误给A加分

最终做好运行效果如下:

1、添加球员信息

2、给记录在案的运动员在场上加分。

 

3、数据库信息:

三层架构结构图:

代码规范:(为目前的开发制定合适的规范):代码风格的原则,简明,易读,无二义性。

缩进:四个空格。

行宽:不超过100字符。

括号:在复杂的条件表达式中,用括号清楚地表示逻辑优先级。

断行与空白的{}行:(加代码)

分行:不要把多个语句放在一行上。

命名:

Camel 驼峰命名法:单词连写 无分割符 每个单词大写首字母

类名和接口名 大写第一个单词首字母

注释:要加入必要的注释。

 部分代码:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using Common;
 6 
 7 namespace DAl
 8 {
 9     public class AddScoreDAll
10     {
11         public int AddTeamAScore(string jerseyNum,string cumulative_score)
12         {
13             string sql = "insert into TeamAScore (jerseyNum,cumulative_score) values('"+jerseyNum+"','"+cumulative_score+"')";
14             return SqlHelper.ExecuteNonQuery(sql,null);
15         }
16         public int AddTeamBScore(string jerseyNum, string cumulative_score)
17         {
18             string sql = "insert into TeamBScore (jerseyNum,cumulative_score) values('" + jerseyNum + "','" + cumulative_score + "')";
19             return SqlHelper.ExecuteNonQuery(sql, null);
20         }
21         public int TeamAError(string Bcumulative_score)
22         { 
23             //给B加分
24             string sql="insert into TeamBScore(cumulative_score values('"+Bcumulative_score+"'))";
25             return SqlHelper.ExecuteNonQuery(sql,null);
26         }
27         public int TeamBError(string Acumulative_score)
28         { 
29             //给A加分
30             string sql = "insert into TeamAScore(cumulative_score values('" + Acumulative_score + "'))";
31             return SqlHelper.ExecuteNonQuery(sql, null);
32         }
33     }
34 }
AddScoreDAll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAl;

namespace BLL
{
    public class AddScoreBLL
    {
        AddScoreDAll dal = new AddScoreDAll();
        public bool AddTeamAScore(string jerseyNum, string cumulative_score)
        {
            return dal.AddTeamAScore(jerseyNum,cumulative_score) > 0;
        }
        public bool AddTeamBScore(string jerseyNum, string cumulative_score)
        {
            return dal.AddTeamBScore(jerseyNum, cumulative_score) > 0;
        }
        public bool TeamAError(string Bcumulative_score)
        {
            //给B加分
            return dal.TeamAError(Bcumulative_score)>0;
        }
        public bool TeamBError(string Acumulative_score)
        {
            //给A加分
            return dal.TeamBError(Acumulative_score)>0;
        }
    }
}
AddScoreBLL
using System;
using System.Collections.Generic;
using System.Linq;
using Common;
using System.Text;

namespace DAl
{
    public class CompareDAL
    {
        //获取TeamA的累计分数
        public int TeamAScore()
        {
            string sql = "select cumulative_score from TeamAScore where id in (select max(id) from TeamAScore);";
           // string str=SqlHelper.ExecuteScalar(sql,null).ToString();
            object o = SqlHelper.ExecuteScalar(sql,null);
            string str;
            if (o != null)
            {
                str = o.ToString();
            }
            else
            {
                str = "0";
            }
            return int.Parse(str);
        }
        //获取TeamB的累计分数
        public int TeamBScore()
        {
            string sql = "select cumulative_score from TeamBScore where id in (select max(id) from TeamBScore);";
           // string sqll = "select cumulative score from TeamBScore where Max(id)";
            //string str = SqlHelper.ExecuteScalar(sql, null).ToString();
            object o = SqlHelper.ExecuteScalar(sql, null);
            string str;
            if (o != null)
            {
                str = o.ToString();
            }
            else
            {
                str = "0";
            }
            return int.Parse(str);
        }
    }
}
CompareDAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAl;

namespace BLL
{
    public class ComPareBLL
    {
        //比较TeamA和TeamB的分数
        //改为25为正常
        
        int a = 25;
        public bool IsAContinueAdd()
        {

            CompareDAL dal = new CompareDAL();
            int TeamAScore = dal.TeamAScore();
            int TeamBScore = dal.TeamBScore();
            if(TeamAScore<a)
            {
                return true;
            }
            else if (TeamAScore >= a && TeamAScore > TeamBScore + 1)
            {
                return false;
            }
            else
            {
                return true;
            }
            
        }
        public bool IsBContinueAdd()
        {
            CompareDAL dal = new CompareDAL();
            int TeamAScore = dal.TeamAScore();
            int TeamBScore = dal.TeamBScore();
            if (TeamBScore < a)
            {
                return true;
            }
           else if (TeamBScore > a && TeamBScore > TeamAScore + 1)
            {
                return false;
            }
            else
            {
                return true;
            }

        }
    }
}
ComPareBLL
原文地址:https://www.cnblogs.com/zyadmin/p/6569240.html