Third online work, pair programming

Source: Internet
Author: User

Title: Write a "software" that can arithmetic integers between 0--10
The program can receive the integer answer entered by the user and judge the right and wrong
At the end of the program, count the number of questions answered correctly and wrongly.
Additional note: 0--10 integers are randomly generated
The user can use the keyboard input to select one of the arithmetic, such as input 1 for the addition operation
The user enters a character with the keyboard to end the run of the program and display statistical results, such as the end of the input e program and display of statistical results
Programming languages are unlimited, command-line output and image interface output are all possible.
On this basis, do incremental development.
Incremental content: 1) to handle the user's error input, such as input letters or symbols, processing the denominator in the division operation in the case of 0, processing the result is negative, to ensure that the primary level does not appear negative, such as can not appear 5-8=-3 this situation;
2) User can set the countdown;
3) The user can set the range of random integers and the number of questions;
4) The user can choose which type of calculation, such as subtraction, or can choose the software randomly generated arithmetic one.

Demand analysis

When the user input 1,2,3,4 represents +,-,*,/respectively, the program will generate random two numbers according to the randomly generated range of user input, and the program will automatically generate two random numbers when the user clicks the start Timing or confirmation button. And the resulting two number of the first number must be greater than the second number will not appear negative.

The user can also enter the time to be timed, thus counting the countdown. When the time is down, the time is up and the form two is displayed, and the statistic results.

At the same time the user can also enter the total number of questions to answer. When the answer to the total number of questions will also pop up the statistical results of the form two!

Statistical results will also pop up when you click the Stop button!

The program will close when the user clicks the Close button!

<2> Design Ideas

Create a Windows Form, design a form, and write code based on the design of your form!

Because you want to get the values in the text box, and you want to count the correct total and total number of questions, define the variables first!

The random number is then generated using the Suiji () method.

Then the technical TextBox3 of the KeyDown event code is written!

Click Stop, the button pops up form two!

Form2 total number of questions, correct totals, and errors in total and correct rate!

Implementation of <3> Code

Form1 's Code

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceCalculator 1{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        //Defining Variables         Public Static intCount =0;  Public Static intright =0;  Public Static intSun;  Public Static intLi;  Public Static intza;  Public Static intShi=0; Private voidSuiji ()//randomly generate two numbers!{Random ra=NewRandom (); Li=int.            Parse (Textbox4.text); Za=int.            Parse (Textbox5.text); intA, B; A=RA.            Next (Li, za); b=RA.            Next (Li, a); TextBox1.Text=a.tostring (); TextBox2.Text=b.tostring (); TextBox3.Text=""; Count++; }        Private voidSUANFA ()//calculation Method        {            strings =JSFs.            Text; Switch(s) { Case "1": Ji. Text ="+";  Break;  Case "2": Ji. Text ="-";  Break;  Case "3": Ji. Text ="*";  Break;  Case "4": Ji. Text ="/";  Break; }        }        Private voidButton1_Click (Objectsender, EventArgs e) {Shi=int.            Parse (Textbox7.text); Label5. Text=Shi.            ToString (); Timer1. Enabled=true; Timer1. Interval= +; Timer1.            Start ();            Suiji ();        Suanfa (); }        Private voidTimer1_Tick (Objectsender, EventArgs e) {                       if(shi<=0) {timer1. Enabled=false; Textbox3.enabled=false; MessageBox.Show ("Time to go! "); Form2 da=NewForm2 (); Da.            ShowDialog (); } Shi= Shi-1; Label5. Text=Shi.                    ToString (); }        Private voidTextbox3_keydown (Objectsender, KeyEventArgs e) {            strings =ji.            Text; Switch(s) { Case "+": Sun=int. Parse (TextBox1.Text) +int.                    Parse (TextBox2.Text);  Break;  Case "-": Sun=int. Parse (TextBox1.Text)-int.                    Parse (TextBox2.Text);  Break;  Case "*": Sun=int. Parse (TextBox1.Text) *int.                    Parse (TextBox2.Text);  Break;  Case "/": Sun=int. Parse (TextBox1.Text)/int.                    Parse (TextBox2.Text);  Break; }            if(E.keycode = =keys.enter) {inti =0; stringan =TextBox3.Text; if(int. TryParse (AN, outi) = =false) {MessageBox.Show ("the numbers you've lost are illegal! "); }                if(TextBox3.Text = =Sun. ToString ()) { Right++;                               } Suiji (); stringz =Textbox6.text; intQ =int.                Parse (z); if(Count = =q) {timer1. Enabled=false; Textbox3.enabled=false; Form2 da=NewForm2 (); Da.                                ShowDialog (); }                            }        }        Private voidButton2_Click (Objectsender, EventArgs e) {timer1. Enabled=false; Textbox3.enabled=false; Form2 da=NewForm2 (); Da.        ShowDialog (); }        Private voidButton4_Click (Objectsender, EventArgs e)            {Suiji ();        Suanfa (); }        Private voidButton3_Click (Objectsender, EventArgs e) {             This.        Close (); }

Form2 's Code

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceCalculator 1{ Public Partial classForm2:form { PublicForm2 () {InitializeComponent (); }        Private voidForm2_load (Objectsender, EventArgs e) {TextBox1.Text=Form1.count.ToString (); TextBox2.Text=Form1.right.ToString (); TextBox3.Text= ((Form1.right/(Double) (Form1.count)) * -). ToString () +"%"; Textbox4.text= (Form1.count-form1.right).        ToString (); }    }}

Code implementation

PSP Time Consuming

PSP2.1 Personal Software Process Stages Time (h)
Planning Plan 8
Estimate How long does it take to estimate the task? 8
Development Development
Analysis Demand analysis 2
Design Spec Creating a design Document
Coding Standard Code specification 1
Design Specific design 2
coding Specific code 3
Code Review Code review 2
text Test 1
Reporting Report
Test Report Test report
Size Measurement Computational effort

0.5

Postmortem Summary afterwards

1

Summarize

For this job wrote three times, did not save, are lost, may summarize the last two summed up well! This assignment is pair programming, I am looking for I often discuss the problem together, but also a more tacit understanding, but two people

Ability is not enough, the total feeling is not satisfied with the exception to do, do bad, or is not very satisfied, do the program, feel or have a good partner, a person found the opportunity is too small, pair programming, can be very good hair

Now the problem, at the same time to make up for insufficient, can learn from each other, improve each other, this is a very good learning method, thanks to the teacher to provide such a good learning method, I will work hard!

Third online work, pair programming

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.