How long does it take to stay?

Source: Internet
Author: User

A demand analysis

This time the teacher for us out a arithmetic program topic, then next, I first talk about this procedure needs analysis. Arithmetic, figures in 1-10, can think of the application of this program for the first grade to the third grade (self-feeling, do not exclude other grades) The main demand may appear in schools, families and educational institutions and some of the teaching site above, Because they may give students some simple math problems, and this procedure just solves this problem, I think, the product needs must first know what the user needs, to customer-centric. And this product just solves this problem. So, I feel that the demand for this product should be very good.

Two design ideas

1 Users The first step must first select a feasible operation, the implementation of this event using a drop-down list of the way, feel that this method is relatively convenient, user-friendly operation, and readability is strong

2 The system will automatically generate two random 1-10 numbers, using the randnum method

3 After the random number is generated, we will calculate the two numbers, in order to facilitate the invocation of the function, we use switch method, in order to reduce the number of code.

4. When this problem is completed, if the user clicks on the next question, then we will proceed to the next question, and execute the call of the Operation method. If the user clicks the end, it pops up the total number of questions, the correct number, the number of errors, the correct rate, etc., and cannot operate on the Operation form.

Four PSP Analysis

Five code writing

Form1 Code:


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;//define the total number of topics, correct number, arithmetic variable
public static int right = 1;
public static int sum;
public Form1 ()
{
InitializeComponent ();

private void Form1_Load (object sender, EventArgs e)
Span style= "color: #ffcc00; font-size:14px; " > {

}
private void Randomnum ()//define random random number generation method
{
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)//define a method for swapping arithmetic
{

string str = comboBox1.SelectedItem.ToString ();
randomnum ();
switch (str)
{
Case "addition":

sum = Int. Parse (TextBox1.Text) + int. Parse (TextBox2.Text);
Break ;
Case "subtraction":
sum = Int. Parse (TextBox1.Text)-int. Parse (TextBox2.Text);
Break ;
Case "multiplication":
sum = Int. Parse (TextBox1.Text) *int. Parse (TextBox2.Text);
Break ;
Case "Division":
sum = Int. Parse (TextBox1.Text)/Int. Parse (TextBox2.Text);
Break ;
Default:
Break ;

}
}

private void Button3_Click (object sender, EventArgs e)//title The correct number of additions and random number calls
{

if (TextBox3.Text = = Sum. ToString ())
{
right++;
Randomnum ();

}
Else
{
Randomnum ();
}


}

private void Button2_Click (object sender, EventArgs e)//specific event at end of Click
{

textbox3.enabled = false;
Form2 frm2 = new Form2 ();
Frm2. ShowDialog ();
This. Close ();

}
}
}



Form2 Code:

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 ();
}
}
}

Six code tests

Vii. Summary

This is a self-made the first small program, now to do the summary of this procedure and feelings to everyone say it.

Do procedures in the process encountered a lot of difficulties, I did a few versions of the program in the morning, there are certain problems, to intermediate some feel do not go down, but after analysis, access to information, or slowly overcome. Many of the methods in the middle come from the content of the textbook, I try my best to fix some problems, but I still found some problems at the end, I can not find the reason, the middle of the test seems to be a bit of a problem. (Haha maybe the brain is too stupid, short-circuit it.) However, I will certainly correct these problems!

The next step is my summary of the process of doing the procedure:

1. Be sure to plan ahead, it can be said that the whole process of design analysis, otherwise, to later there will be a lot of trouble, even may be redo!

2. To have patience, knocking code is a boring project, we must use patience, perseverance, overcome it.

3. Lack of practice, the actual combat ability is poor, will strengthen the practice in the future.

3. The basic knowledge is relatively deficient, and the basic knowledge must be studied diligently.

...........

This is the procedure to do the whole process, I hope the teacher criticize correct it! Thank you!

How long does it take to stay?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.