2017-2018-2 20172314 "Java Programming" course pair programming Exercises _ arithmetic

Source: Internet
Author: User
Tags arithmetic

Arithmetic first week summary Requirements analysis (Fang)
    • Can randomly generate any multi-channel arithmetic problem identified by the user
    • The difficulty level of the topic can be selected, or you can choose not to do mixed operation.
    • The problem arithmetic realizes the infix expression to the suffix expression and calculates.
    • Can judge the right and wrong, and calculate the correct rate.
    • Operations that support true fractions.
Design ideas (output UML class diagram at the same time) (Fang) No stack
    • First of all to determine the number of generated problems, you can use a loop, using scanner, the number of cycles by the user input determined.
    • The generation of formulas
      • Write a class to implement integer arithmetic: Define two integers numerator and denominator, and use the int nextint (4) method to randomly output 1234 integers representing the subtraction operation, respectively. The numerator and denominator subtraction operations are then performed based on the operators implemented by the random output.
      • Write a class to achieve the arithmetic of the score: use the seventh chapter of the book Rationalnumber and Rationaltester class can be achieved.
      • Also need to determine the right and wrong operation, and output scores and correct rate. Then write a class, compare the result of the operation with the value entered by the user, use the If-else statement to output "correct" or "error" and use "X + +" to count the correct number of questions, and divide the total number of topics to get the correct rate.
    • This approach is only the beginning of the simple idea, and did not implement all the required functions, such as "to achieve infix expression to postfix expression and calculation," after the teacher finished the knowledge of the stack further conceived.
There are stacks
    • Create a formula: First, let the user choose the difficulty level of the topic, corresponding to the number of different numbers to operate, determine the number of randomly generated integers, define two integers numerator and denominator represent the numerator and denominator. The generation of fractions uses the seventh chapter of the book Rationalnumber class and Rationaltest class (you can also call this method only for fractional calculation), and then call the function StringTokenizer the fraction as a string type, Then at the same time call to produce fractions and integer mix, and then use a Hasmoretokens method to traverse all the number, encountered the string type of the proposed, encountered the integer type of it as a molecule, the denominator is 1, and then put these numbers in the set of stack 1 (all points), and then set up another stack 2, using The int nextint (4) method randomly outputs 1234 integers (the resulting number is minus one of the number in the Stack 1), represents the subtraction operator, stores the number in the stack, reads a number from the stack 1, reads an operator of Stack 2, and then proceeds to read the stack 1 until all the numbers are read. And then output these numbers, at this time these numbers are the string type of fractions, return the string and then use Next loop, a separate, fractions in the infix suffix, 2/3 for a whole, turn to suffix, claiming to come out again a string, separate after next out of a score, create an object to customize to/ Separate the separators. The result is that the reduction and GCD methods of the Rationalnumber class are used to simplify the results, the result is that the fractional form is preserved, and the result of the false fraction is an integer.
    • Judge the wrong: the user input number and the results of the computer comparison, the output is wrong. If the answer is a score, compare the numerator denominator to judge.
    • Statistics correct rate: with a cycle, when the right and wrong to determine the correct, the correct problem number plus one, the final total and the number of problems can be divided.
UML Diagram (Tan Xin)
PSP (Wang Yuhan)
PSP2.1 Personal software Process Stages Estimated time-consuming (hours) actual time elapsed (hours)
Planning Plan 1 1
Estimate Estimate how long this task will take 20
Development Development 2 10
Analysis Demand analysis (including learning new technologies) 2 2
Design Spec Creating a design Document 1 1
Design Review Design Review (and colleagues review design documents) 0.5 2
Coding Standard Code specification (to develop appropriate specifications for current development) 0.5 0.5
Design Specific design 2
Coding Specific code 2
Code Review Code review 1
Test Test (self-test, modify code, commit changes) 1
Reporting Report 2
Test Report Test report 2
Size Measurement Computational effort 1
Postmortem & Process Improvement Plan Summarize afterwards and propose process improvement plan 1
Code specification (Wang Yuhan)
    • According to the format specification of idea, the default indentation format is 4 spaces, which is indented with the TAB key.
    • Code naming is straightforward and contains the necessary information to help understand the code.
Problem
    • Problem one: At first, I didn't know how to perform complex operations, so I thought about the method without the stack.
    • Problem solved: After the teacher explained the use of the stack, by implementing the infix expression to the suffix expression and calculated.
    • Question two: How to allow fractions to participate in the calculation of infix suffix expressions, rather than being directly counted as division.
    • Problem two solution: The problem our group discussed is to use the Rationalnumber two classes as part of the book, with the prefix suffix expression of the calculation separated, as part of a separate calculation score, but this is inconsistent with the experimental requirements, after asking the TA, He tells us a StringTokenizer method, which can use a custom string as a token, so that the division symbol is "%", the fraction is "/" to distinguish, the numerator denominator is extracted, so that all integers are also used as the denominator of 1 of the score to be calculated, and then converted.
Good friends of pairing programming
    • 20172323 Wang Yuhan: infix turn suffix
    • 20172314 Fang: Calculation of suffix expressions
    • 20172305 Tan Xin: The output of infix expression
Team Experience

In our team, I am responsible for writing requirements analysis and design ideas, Tan Xin is responsible for making UML class diagram, Wang Yuhan is responsible for making PSP map and determine code specifications. These are the first week of everyone's general division of Labor, everyone responsible for the part has been discussed with the players, such as I am responsible for writing the design ideas, is to discuss together to find inappropriate local changes, after the teacher and the teaching assistant revised again after the explanation. In general, the team's opinion is basically consistent, and can reasonably solve the views of the team members, so teamwork is very efficient.

Reference
    • 2017-2018-2 1723 "Java Programming" course pair programming Exercises _ arithmetic
    • Arithmetic Periodic summary

2017-2018-2 20172314 "Java Programming" course pair programming Exercises _ arithmetic

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.