才幾級的堅持多久

來源:互聯網
上載者:User

標籤:

一 需求分析

       本次老師為我們出了一道四則運算的程式題目,那麼接下來,我首先談談這個程式的需求分析。四則運算,數字在1-10,可以想到本程式的適用對象為小學一年級到三年級(自我感覺,並不排除其他年級 )主要需求可能會出現在學校,家庭和教育機構還有部分教學網站上面,因為他們可能會給學生出一些簡單的數學題目,而這一程式正好解決了這一個問題,我想,產品的需求必須首Crowdsourced Security Testing道使用者需要什麼,要以客戶為中心。而這個產品正好解決了這個問題。所以,我感覺這個產品的需求應該挺不錯的。

 

二 設計思路

 

  1 使用者第一步必須先選擇一種可行的運算方式,這個事件的實現採用了下拉式清單的方式 ,感覺這個方法比較便捷,使用者操作方便,且可讀性較強

 

  2 系統會自動產生兩個隨機1-10數字,採用randnum的方式

 

  3 隨機數字產生之後,我們就要計算這兩個數字,為了方便調用函數,我們採用switch的方式,以便減少代碼的數量。

 

   4.當此題目運算完畢後,使用者如果單擊下一題,那麼我們會進行下一題的計算,並且執行運算方法的調用。如果使用者單擊結束時,則會彈出 題目的總數量,正確數量,錯誤數量,正確率等,且不能對運算表單進行操作。

 

 

四 PSP分析

 

五  代碼書寫

 

Form1代碼:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sizeyunsuan
{
public partial class Form1 : Form
{
public static int count = 0; //定義題目總數,正確數,四則運算的變數
public static int right = 1;
public static int sum;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}
private void RandomNum() //定義隨機產生隨機數的方法
{
Random ran = new Random();
int n1, n2;
n1 = ran.Next(1, 11);
n2 = ran.Next(1, 11);
textBox1.Text = n1.ToString();
textBox2.Text = n2.ToString();
textBox3.Text = "";
count++;

}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) //定義調換四則運算的方法
{

string str = comboBox1.SelectedItem.ToString();
RandomNum();
switch (str)
{
case "加法":

sum = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
break;
case "減法":
sum = int.Parse(textBox1.Text) -int.Parse(textBox2.Text);
break;
case "乘法":
sum = int.Parse(textBox1.Text) *int.Parse(textBox2.Text);
break;
case "除法":
sum = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
break;
default:
break;

}
}

private void button3_Click(object sender, EventArgs e) //題目正確數量的相加和隨機數調用
{

if (textBox3.Text == sum.ToString())
{
right++;
RandomNum();

}
else
{
RandomNum();
}


}

private void button2_Click(object sender, EventArgs e) //單擊結束時的具體事件
{

textBox3.Enabled = false;
Form2 frm2 = new Form2();
frm2.ShowDialog();
this.Close();

}
}
}



Form2代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sizeyunsuan
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = Form1.count.ToString();
textBox2.Text = Form1.right.ToString();
textBox3.Text = ((Form1.right / (double)(Form1.count)) * 100).ToString() + "%";
textBox4.Text = ((Form1.count -(double)(Form1.right)) ).ToString();
}
}
}

 

六 代碼測試

 

七  總結

 這個算是自己做的第一個小程式吧,現在對做這個程式的總結和感想對大家說一下吧。

   做程式的過程當中遇到過許多困難,我一個上午做了幾個版本的程式,都有一定的問題,到中間環節有的感覺做不下去了,但是經過分析,查閱資料,還是慢慢的克服了。中間的許多方法來自於課本上所講的內容,我盡我最大的努力把一些問題修複了,但是我在最後還是發現了一些問題,實在找不出原因了,中間的測試好像也有點問題。(哈哈  也許腦子太笨了,一時短路吧。)不過,這些問題我一定會改正的!

 接下來是我對做程式這一個過程的總結:

1.一定要事先做好計劃,可以說是對整個程式的設計分析,否則,到後來會有許多麻煩,甚至有可能會重做!

2.做事要有耐心,敲代碼是件枯燥的工程,我們一定要用耐心,恒心,克服它。

3.缺乏練習,實戰能力差嗎,今後會加強練習的。

3.基礎知識比較欠缺,還得努力學習基礎知識。

...........

這就是程式做的整個過程了,希望老師批評指正嗎!謝謝啦!

 

才幾級的堅持多久

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.