16周第一組作業

來源:互聯網
上載者:User

標籤:result   log   技術   設計   textbox   init   需求分析   更新   led   

計劃:估計這個程式需要6天完成

開發:

   需求分析:作為一個記分員,我希望系統能夠記錄每個隊伍的得分

   拆分使用者故事:作為一個記分員,我希望能夠系統能夠有加分減分的功能,以便能及時更新比分資訊

                       作為一個記分員,我希望能夠系統能夠有計分板功能,讓我瞭解每次比分情況

 

設計文檔:本程式是個排球記分員的程式,可以協助記分員詳細的瞭解參賽隊伍的比分情況

程式具體功能:

記分員開啟本程式後,選擇參賽隊伍,會在介面顯示比分情況,局次也為0,本局比分預設都為0,總比分也都為0,

有兩個加一分按鈕,兩個減一分按鈕,每個按鈕對應選擇的隊伍,

還有一個結果按鈕,點擊結果按鈕,會在計分板裡顯示比賽情況,並判斷本局情況。

同時局次加一,局次每5次一迴圈

點擊重設按鈕,介面所有資料清空,恢複預設值

記分員加分錯誤後,點擊減一分按鈕,會減少本隊伍一份,並給對方隊伍加一分

具體設計活動圖表如下

 

代碼如下:

 

public partial class Jifenyuan : Form
    {
        public Jifenyuan()
        {
            InitializeComponent();
        }

        private void buttonAddteam1_Click(object sender, EventArgs e)//加一分按鈕
        {
            textBoxJufen1.Text = (Convert.ToInt32(textBoxJufen1.Text) + 1).ToString();
        }

        private void buttonAddteam2_Click(object sender, EventArgs e)//加一分按鈕
        {
            textBoxJufen2.Text = (Convert.ToInt32(textBoxJufen2.Text) + 1).ToString();
        }

        private void buttonMinusTeam1_Click(object sender, EventArgs e)//減一分按鈕,本隊減一分,對方隊加一分
        {
            if (Convert.ToInt32(textBoxJufen1.Text)<1)
            {
                buttonMinusTeam1.Enabled = false;
            }
            else if (Convert.ToInt32(textBoxJufen1.Text) > 1)
          
            {
                textBoxJufen1.Text = (Convert.ToInt32(textBoxJufen1.Text) - 1).ToString();
                textBoxJufen2.Text = (Convert.ToInt32(textBoxJufen2.Text) + 1).ToString();
            }
        
        }

        private void buttonMinusTeam2_Click(object sender, EventArgs e)//減一分按鈕,本隊減一分,對方隊加一分
        {
            if (Convert.ToInt32(textBoxJufen2.Text) < 1)//當分數小於1,減一分按鈕不能用
            {
                buttonMinusTeam2.Enabled = false;
            }
            else if (Convert.ToInt32(textBoxJufen1.Text) > 1)
            {
                textBoxJufen2.Text = (Convert.ToInt32(textBoxJufen2.Text) - 1).ToString();
                textBoxJufen1.Text = (Convert.ToInt32(textBoxJufen1.Text) + 1).ToString();
            }
        }

        private void buttonResult_Click(object sender, EventArgs e)
        {
            textBoxJu.Text = (Convert.ToInt32(textBoxJu.Text) + 1).ToString();//局數加一
            if (Convert.ToInt32(textBoxJu.Text)>6)//局數每五次一迴圈
            {
                int i = 0;
                i = Convert.ToInt32(textBoxJu.Text);
                i++;
            }
            if (Convert.ToInt32(textBoxJu.Text)<5)//前四局的判斷方法
            {
                if (Convert.ToInt32(textBoxJufen1.Text)-Convert.ToInt32(textBoxJufen2.Text)>=2 || Convert.ToInt32(textBoxJufen1.Text)>=25)//判斷方法
              {
                  textBoxTeamScore1.Text = (Convert.ToInt32(textBoxTeamScore1.Text) + 1).ToString();
              }
                else if (Convert.ToInt32(textBoxJufen2.Text)-Convert.ToInt32(textBoxJufen1.Text)>=2 || Convert.ToInt32(textBoxJufen2.Text)>=25)
                {
                    textBoxTeamScore2.Text = (Convert.ToInt32(textBoxTeamScore2.Text) + 1).ToString();
                }
            }
            if (Convert.ToInt32(textBoxJu.Text)==5)//第五局的判斷
            {
                if (Convert.ToInt32(textBoxJufen1.Text)==15)
                {
                    textBoxTeamScore1.Text = (Convert.ToInt32(textBoxTeamScore1.Text) + 1).ToString();
                }
                else if (Convert.ToInt32(textBoxJufen2.Text)==15)
                {
                    textBoxTeamScore2.Text = (Convert.ToInt32(textBoxTeamScore2.Text) + 1).ToString();
                }
                buttonRestting_Click(null,null);
            }
            if (textBoxJufen1.Text=="3")
            {
                MessageBox.Show(comboBoxTeam1.SelectedItem+"贏了");
            }
            else if (textBoxJufen2.Text=="3")
            {
                MessageBox.Show(comboBoxTeam2.SelectedItem + "贏了");
            }
            textBoxJifenban.Text = "參加比賽的兩個隊伍分別是" + comboBoxTeam1.SelectedItem + comboBoxTeam2.SelectedItem + "    \n他們的比分是" + textBoxTeamScore1.Text+"和"+textBoxTeamScore2.Text;
            
        }

        private void buttonRestting_Click(object sender, EventArgs e)
        {
            textBoxJufen1.Text = "";
            textBoxJufen2.Text = "";
            textBoxJu.Text = "";
            textBoxTeamScore1.Text = "";
            textBoxTeamScore2.Text = "";
            buttonMinusTeam1.Enabled = false;
            buttonMinusTeam2.Enabled = false;
        }
    }

 

16周第一組作業

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.