Pair programming Replay - small high number of early learning system

         Foreword

        Before, there are individual projects done little to generate high early papers. In this project, I spent a lot of time learning to write ui interface, create a listener realize the function response. For javax.swing. * Jframe frame using lightweight components, and in various packages have some experience. You can be rewritten to achieve the effect by their favorite class. Monitor settings are also used a lot. Button on the monitor, use actionlistener and so on.

        In this process, I also try to listen to the label, the label found on a listener listens only corresponds to a label, or can not determine which tab clicks. This is the experience I gained in individual events.

        The pair programming for me and my partner Qiao Xiangshuo after discussion, this time he was responsible for the construction and design of the whole framework of ui, I was responsible for my weakness early personal project: Title of generation and partial results of operations, equivalent to each other weaknesses were deeper consolidation, to achieve a common purpose to improve.

        Closer to home

        Previous:

        Teammate Qiao Xiangshuo clear thinking, the program is divided into several parts for a moment: SMS verification code function realization, UI interface to achieve, achieve the title function, subject to calculate the correct answers with the four options given. He is responsible for the login screen, SMS verification, change the password and select the topic and type do captioned interface. Bear the entire framework program, and most of the work. Like the real-name point here.

       The overall framework constructed from Joe, I am responsible for the results and give the correct title and four options. So how do two people achieve precision docking, how unified interface, is the question we initially consider. Here, after careful consideration, we decided that he passed me a String type of question categories, and a number of type int topic. And I will take the title of the list is stored, the correct answer, analog four options out. Then type in the title list stored data by calling out. In his list of values ​​there can be removed by calling the class to display the topic in question do on screen.

      After the agreed Well, I started my work: the topic, considered answer.

 

      Mid-:

      Here calculation formula for randomly generated too much I will not go into details. I will focus energy on how to calculate a square root, square, multiplication, division sign, sin, tan, cos, +, -, multiple brackets equation.

      Troops and horses, forage first. Prerequisite to win a battle is to be well prepared. I checked some relevant information, most of them are solved using reverse Polish notation. By actually define the priority, and then stack the stack, in order to calculate the computer habits. Probably read, but also feel dull. I did not use.

      In thinking partner- Qiao Xiangshuo of operands operation, I had to dig deep and practical exploration. The final completion of the final calculation code.

      Analysis of Algorithms:

      To ignore the root, we know that for addition, subtraction, square root, square, trigonometric functions, and square root, trigonometric higher priority, then is Math. If we operand is operating object, it is the first of his root, trigonometric, square processing. Only the formation of operations of addition, subtraction, then multiplication and division, and finally addition and subtraction. It looks simple enough, right.

      But encountered parentheses how to do it?

      The solution is to be seen as a whole number in parentheses operation to deal with.

     So the question again, enclosed value equation is not known, how we deal with it on her operation?

      Recursion is solved!

      Recursive return value of the expression in parentheses, as a number of the current operation, calculates.

       A to B (c + d) E

       As the above formula, remember to do a total of four operand. We traverse around them, remove the root arithmetic, trigonometric, square. Then the same operation as the beginning.

       Of course, this is a String type, operation is very complex. Write down the following algorithm steps.

      1. Define a function arithmetic double Calculate (char [] ch, left, right) ch name is a string array, left, right around the position of the brackets. Why, for the convenience of recursion. If the formula is not about the beginning of the brackets, you can add in dealing with this function. Function returns the current value of the expression in parentheses.

      2 defines three arrays, the recording start position of each operand, the termination position value. For a non-simple brackets operand fetch his values, for the brackets, which value [k] = Calculate (char [] ch, left, right);

      3. operands before and after each traversal of root, trigonometric functions, calculates the square, then change the value of the value, and the start position corresponding extended operand.

      4. After the above operations, each fully connected between by a number of arithmetic operations and the number of the starting position. We string from left to right traversal of the current range, or in addition to find the multiplication number, by comparison to the starting position, a front and a rear operand find operands, the calculation result of the presence of a value in the operand , then changed to its initial position before the start position of an operand. An operand value before and cleared.

     5. Finally traversal operand, if prior to the start position plus sign is added in the answer, the answer in minus is subtracted. Not directly added to the addition and subtraction results in. And answer return.

     As ideas, the code is still finishing they would not be uploaded. I want to see friends can also try this idea to write its own calculator.

    Late:

    The main job is to late to find bug, a very wonderful about the formula to improve the results. Qiao Xiangshuo my partner and found a little bug, and all resolved.

    1. Repeat the random option

    2. Because of the random option is to refer to the correct answer, the correct answer is zero when the option is also zero.

    3. Optimize for multiple nested parentheses.

    4. If the answer is an integer, random out of options there might be a problem decimals. This answers questions at a glance, regarded bug.

    The value of the root of a negative number, or the denominator is 0, or avoid tan90 degree, and the problem is not fully displayed in scientific notation. We determine if this problem occurs on a heavy.

       We have been completed for more than bug fixes. If you see an assistant can personally verify. Hey.

    Finally, very grateful to my partner, I followed him really learned a lot, lifting scheme, naming conventions and other functions.

       

     

Guess you like

Origin www.cnblogs.com/MR-miao-kk/p/11605481.html