Peer project-Upgrade of four arithmetic "Software"

Source: Internet
Author: User

The reason: https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/2213

Githup reason: https://github.com/tianshizhao/tianshizhao

I. Basic Requirements

Starting from a personal project, the program is transformed into a single-Host Program with the user interface (not the console). The most basic program is:

  • Automatically generates questions. A single question can contain up to four operators and the operands are less than 100.
  • Users can enter answers
  • If the answer entered by the user is correct, a prompt is displayed. If the answer is incorrect, an error is prompted and the correct answer is displayed.

Ii. Expansion direction

  1. After a user answers a question, the program displays the time used by the user to answer the question.
  2. You can select the number of questions (up to five questions). After the answer is over, you can view the number of wrong questions and the number of correct questions.
  3. The program can produce the question of a single integer factorial: for example, 4! = 24
  4. The program can set the skin function to change the color of the interface (click the button to achieve Random Switching of the eight colors)
  5. The program can set the Answer time, the time is set to an integer, the unit is seconds, the maximum cannot exceed 120 seconds, if the answer time exceeds the Answer time did not answer, the prompt: the time has reached, cannot answer.

Iii. debugging in the development environment: intelij idea

4. Estimate the implementation time and record the Pair programming time.

 

Psp2.1 Personal software process stages Time senior student Time
Development Development 50 60
· Analysis Demand Analysis (including learning new technologies) 30 35
· Design spec Generate design document 0 0
· Design Review Design Review 0 0
· Coding standard Code Specification 5 8
· Design Specific design 30 35
· Coding Code 45 60
· Code review Code Review 3 5
· Test Test (self-test, code modification, and modification submission) 5 8
Reporting Report 0 0

 

V. Code Implementation

 Form code

 

1 JSJ () 2 {3 super ("Easy calculator upgrade"); 4 This. setdefaclocloseoperation (jframe. exit_on_close); 5 this. setsize (1000,500); 6 a = new jlabel ("Number of input questions:"); 7 B = new jlabel ("time :"); 8 C = new jlabel ("set time (less than 120 seconds):"); 9 d = new jlabel ("question:"); 10 E = new jlabel ("Answer: "); 11 F = new jlabel (" judgment: "); 12 number = new jtextfield (10); 13 button1 = new jbutton (" generate question "); 14 button4 = new jbutton ("Change Background"); 15 button4.addactionlistener (this); 16 N = new jtextfield (10); 17 useranswer = new jtextfield (10); 18 useranswer. addactionlistener (this); 19 flase = new jtextfield (15); 20 Showtime = new jtextfield (10); 21 showtime. addactionlistener (this); 22 settingtime = new jtextfield (10); 23 settingtime. addactionlistener (this); 24 timer timertask = new timer (1000, this); 25 this. timer = timertask; 26 button3 = new jbutton ("Submit"); 27 button3.addactionlistener (this); 28 button2 = new jbutton ("Next question"); 29 button2.addactionlistener (this ); 30 number. addactionlistener (this); 31 button1.addactionlistener (this); 32 G1 = new jpanel (); 33 g2 = new jpanel (); 34 G3 = new jpanel (); 35 getcontentpane (). add (G1, "North"); 36 getcontentpane (). add (G2, "center"); 37 getcontentpane (). add (G3, "South"); 38 g3.add (button4); 39 g3.add (menubar); 40 g1.add (c); 41 g1.add (settingtime); 42 g1.add (); 43 g1.add (number); 44 g2.add (button1); 45 g2.add (d); 46 g2.add (n); 47 g2.add (E); 48 g2.add (useranswer ); 49 g2.add (f); 50 g2.add (flase); 51 g3.add (B); 52 g3.add (Showtime); 53 g3.add (button3); 54 g3.add (button2); 55 This. setresizable (false); 56 this. setvisible (true); 57}

 

 

 

 

Check whether the answers are correct or incorrect.

 

1 If (E. getsource () = menubar. getmenu (1) 2 {3} 4 else if (E. getsource () = button3) 5 {6 S = decimal. format (SUM); 7 if (float. parsefloat (S) = float. parsefloat (useranswer. gettext () 8 {9 right ++; 10 flase. settext ("the entered answer is correct! "); 11 flase. setforeground (color. Red); 12} 13 else14 {15 wrong ++; 16 flase. settext (" error! Correct answer: "+ float. parsefloat (s); 17 flase. setforeground (color. Blue); 18} 19}

 

The number of questions cannot exceed 5. The Question Time cannot exceed 120 seconds.

1 try 2 {3 showtime. settext (string. valueof (settingtime. gettext (); 4 5 Int n1 = 120, n2 = 5; 6 if (N1 <(integer. parseint (Showtime. gettext () 7 {8 joptionpane. showmessagedialog (null, "the time cannot exceed 120 seconds! "); 9 this. setvisible (false); 10} 11 if (N2 <(integer. parseint (number. gettext () 12 {13 joptionpane. showmessagedialog (null, "the number of multiple choice questions cannot exceed 5! "); 14 This. setvisible (false); 15 16} 17 timer. start (); 18 19} 20 catch (nullpointerexception O) 21 {22 system. out. print ("incorrect input"); 23} 24 yunsuan (); 25 showtime. settext (string. valueof (settingtime. gettext (); 26}

 

 

Vi. Running results

 

 

 

 

 

VII. division of labor and cooperation

1. Pair members
  • Myself -- 201606120045 Zhang zhitao:
  • Teammate Tian shizhao (https://www.cnblogs.com/tianshizhao/p/9846335.html)

 

2. Expansion direction
  1. After a user answers a question, the program can display the time used by the user to answer the question (Zhang zhitao)
  2. You can select the number of questions (up to five questions). After the answer is over, you can view the number of wrong questions and the number of correct questions (Zhang zhitao)
  3. The program can produce the question of a single integer factorial: for example, 4! = 24 (Tian shizhao)
  4. The program can set the skin function, you can change the color of the interface (click the button to achieve Random Switching of the eight colors) (Tian shizhao)
  5. The program can set the Answer time, the time is set to an integer, the unit is seconds, the maximum cannot exceed 120 seconds, if the answer time exceeds the Answer time did not answer, the prompt: the time has reached, cannot answer. (Tian shizhao)

 

 8Summary

The two extensions in charge are relatively simple and can be quickly solved, mainly in the form aspect. The teacher mentioned it before when learning java. At that time, I was ignorant of the past.

Without learning how to use the form, it is stuck in the form code. Fortunately, I think back to the instructor's explanation of the form, which makes it easy to understand the reference code on the Internet,

After reading the code several times, it is easy to write the code. It seems that the Foundation is not solid enough. Read more books and practice more.

 

IX. Photos

 

Peer project-Upgrade of four arithmetic "Software"

Related Article

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.