20165104 Meng Fanbin - Pair Programming Exercise (Week 2)

20165104 Meng Fanbin - Pair Programming Exercise (Week 2)

Unfortunately, the difficulty of this pairing exercise is still far beyond the capabilities of both my partners. Pair learning has become paired learning from classmates. Two people asked together, it is indeed more efficient, maintaining this state of study every week, although it is very tiring, but it is indeed much better than the lazy me.
Requirements Analysis
-------------------

Topic requirements

Automatically generate four arithmetic problems in primary school (addition, subtraction, multiplication, division)

Integers are supported

Support for multiple operators (such as generating questions containing 100 operators)

True Score

Statistical accuracy

Extended requirements

Process generated questions and output to file

After completing the question, read it from the file and judge the question

Multi-language support: Simplified Chinese, English

Generated questions cannot be deduplicated

>- De-duplication: The questions generated by the program run once cannot be repeated, that is, any two questions cannot be transformed into the same question by exchanging the arithmetic expressions around + and × for a limited number of times. For example, 23 + 45 = and 45 + 23 = are repeated questions, and 6 × 8 = and 8 × 6 = are also repeated questions. The two questions 3+(2+1) and 1+2+3 are repeated. Since + is left-associative, 1+2+3 is equivalent to (1+2)+3, which is 3+(1 +2), which is 3+(2+1). But 1+2+3 and 3+2+1 are two non-repetitive questions, because 1+2+3 is equivalent to (1+2)+3, and 3+2+1 is equivalent to (3+2 )+1, they cannot become the same topic through a limited number of exchanges.

Realize ideas

Infix expressions are converted to postfix expressions

  • If a number is encountered, we simply output it.
  • If a non-number is encountered, if the stack is empty or the symbol is a left parenthesis or the top element of the stack is a parenthesis, it is directly pushed onto the stack.
  • If a closing bracket is encountered, continue to pop the stack and output the symbol until the top element of the stack is a left bracket, and then pop the left bracket from the stack (note that the left bracket is only popped from the stack, not output), and the right bracket is not pushed onto the stack.
  • If an operation symbol is encountered and the stack is not empty, check the top element of the stack. If the operation priority of the top element of the stack is greater than or equal to the operation symbol, it will continue to pop the stack until the priority of the top element is less than the operator. Finally push the element onto the stack.
  • If we reach the end of the input, pop all elements from the stack in turn.

    Evaluate postfix expressions

    ```
    public int doCal(List

```
Code cloud link

UML class diagram

code framework

learning feelings

Continued the last week's scorching.... It was exactly as I expected

BUT

Thanks my partner. Two people ask their classmates for advice and study together. To be honest, two people do ask together, they don’t know how to communicate with each other, and they are much happier to learn~

  • The photos of paired learning have been put in the blue ink cloud class

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324676132&siteId=291194637