Https://github.com/2392030179/work.git
Companion students:
Huang guoguo 201606120075 https://www.cnblogs.com/666hll1212123/p/9865982.html
1. Starting from a personal project, the program is converted into a single-Host Program with a user interface (not a console), which is basically achieved:
Generate a question. A single question can contain a maximum of four operators and the operand is less than 100.
Users can enter answers
If you enter the correct answer, the system prompts that the answer is correct. If the answer is incorrect, the system prompts that the answer is incorrect and the correct answer is displayed.
2. Eight independent and scalable directions are provided below.
- The program can return a four-digit positive integer operation with parentheses. It supports the score and the Division function keeps two decimal places, for example: (1/3 + 1) * 2 = 2.67. Note: Here is 2.67 rather than 2.66, or keep the score: 8/3
- You can obtain the question that the expression contains a negative integer (the minimum value of a negative integer is not less than-100), and the negative value must contain parentheses. The user input results do not contain parentheses. For example, 2 * (-4) =-8
- After a user answers a question, the program displays the time used by the user to answer the question.
- 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.
- When you answer questions for the first time, you need to enter the user name. After the user starts the next time, the program needs to remember the user name entered previously.
- The program can produce the question of a single integer factorial: for example, 4! = 24
- 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.
- The program can set the skin function to change the color of the interface.
2. Development Environment
Tool: intellij idea
Language: Java
Iii. Division of Labor
Huang jianke:
Interface code writing
Huang guoguo:
Core Algorithm functions
Iv. Running status
V. Summary
Through this experiment, I became more familiar with the interface design and realized that it was not easy to make a good interface.
Core code
public int question(){ Random random=new Random(); int ramNumber1=(int) (Math.random()*100); int ramNumber2=(int) (Math.random()*100); int ramNumber3=(int) (Math.random()*100); String[] operator={"+","-","*","/"}; int operatorIndex1=(int) (Math.random()*4); int operatorIndex2=(int) (Math.random()*4); int resultFirst=0; if (operatorIndex1<operatorIndex2){ resultFirst= arithmetic(ramNumber2,ramNumber3,operator[operatorIndex2]); resultLast= arithmetic(ramNumber1,resultFirst,operator[operatorIndex1]); } else { resultFirst= arithmetic(ramNumber1,ramNumber2,operator[operatorIndex1]); resultLast= arithmetic(resultFirst,ramNumber3,operator[operatorIndex2]); } // System.out.println(ramNumber1+operator[operatorIndex1]+ramNumber2+operator[operatorIndex2]+ramNumber3+"="); question=Integer.toString(ramNumber1)+operator[operatorIndex1]+Integer.toString(ramNumber2) +operator[operatorIndex2]+Integer.toString(ramNumber3)+"="; return resultLast; }
Interface code
Public void mainfram () {Container = getcontentpane (); setlayout (null); setbounds (100,100,120); jbutton setquestion = new jbutton ("Question"); setquestion. setfocuspainted (false); setquestion. setbounds (350,310,100, 50); setquestion. setfont (new font ("", Font. bold, 20); jbutton submitanswer = new jbutton ("Submit"); submitanswer. setfocuspainted (false); submitanswer. setbounds (750,310,100, 50); submitanswer. setfont (new font ("", Font. bold, 20); jtextfield question = new jtextfield (); question. setfont (new font ("", Font. bold, 50); question. setbounds (500,250, 0); jtextfield answer = new jtextfield (); answer. setfont (new font ("", Font. bold, 50); answer. setbounds (350,260,500, 50); jlabel = new jlabel ("Answer area:"); jlabel. setfont (new font ("", Font. bold, 50); jlabel. setbounds (170,260,500, 50); container. add (setquestion); container. add (submitanswer); container. add (question); container. add (answer); container. add (jlabel); setvisible (true); arioperation = new arioperation (); Result = arioperation. question (); question. settext (arioperation. question); submitanswer. addactionlistener (New actionlistener () {@ override public void actionreceivmed (actionevent e) {string judge1 = "correct answer"; string judge2 = "Incorrect answer, correct answer:" + integer. tostring (result); If (integer. parseint (answer. gettext () = Result) New judge (judge1 ). setvisible (true); else new judge (judge2 ). setvisible (true) ;}}); setquestion. addactionlistener (New actionlistener () {@ override public void actionreceivmed (actionevent e) {arioperation = new arioperation (); Result = arioperation. question (); question. settext (arioperation. question );}});}}
Peer project-Upgrade of four arithmetic "Software"