20172319 2018.04.23-05.02
Pair programming exercise _ four arithmetic operations
Phase 1 summary of the first week
content
Pairing objects:
- 20172316 Zhao Ganchen (driver, navigator)
- 20172319 Tang Caiming (driver, navigator)
- 20172319 Wang Wenbin (driver, navigator)
demand analysis:
1. Project content
Write code in paired groups to:
1. Automatically generate questions
Can be used independently (can realize the function of writing test classes to generate questions independently),
and can generate questions of different levels, similar to:
Level 1 questions: two numbers such as 2 + 5 =
10 - 5 =
, one operator title
2. The question operation (judgment)
can be used independently to
realize the conversion of infix expressions into postfix expressions and to calculate
the correctness of the user's answer and output the correct result
3. Support true fractions,
which can be used independently to
realize the calculation of fractional formulas
4. Topic de-duplication (expansion requirements, bonus items)
can be used independently to
achieve de-duplication of automatically generated expressions: as follows
If generated: 2 + 5 =
5 + 2 =
the same topic
2. Understand:
- Can randomly generate n four arithmetic problems, n is input by the user
- Supports whole numbers and fractions
- Support multiple operators, the number of operators can be input by the user
- Able to judge right and wrong, remind and output the correct answer when wrong
- Correct rate can be calculated
Design ideas:
- Due to the difference in the division of labor, individuals complete various parts of the project independently, and I am responsible for supporting the true score part;
- To operate on two fractions, the question must be random. It must be considered that the numerator and denominator of each are random, so four variables are set. Each variable is randomly selected from (-50) to (50). number
- Declare a String class variable to evaluate and output the operator
switch (e) // 运算符号
{
case 0:
s1 = " + ";
break;
case 1:
s1 = " - ";
break;
case 2:
s1 = " × ";
break;
case 3:
s1 = " ÷ ";
break;
}
then toString outputs the equation
s2 = numerator1/denominator1 + s1 + numerator2/denominator2 + " = ";
However, I encountered a problem. Although the output is a fraction, it does not satisfy the
true fraction. In order to ensure that the fraction operation is a true fraction
while (true) {
numerator1 = generactor.nextInt(51) - 50;
denominator1 = generactor.nextInt(51) - 50;
numerator2 = generactor.nextInt(51) - 50;
denominator2 = generactor.nextInt(51) - 50;
e = (int)(Math.random()*4);
a = numerator1;
b = denominator1;
c = numerator2;
d = denominator2;
if (numerator1 >= denominator1 || numerator2 >= denominator2||denominator1==0||denominator2==0||numerator2==0) // 保证真分数(分子分母不为0,分子小于分母)
continue;
else {
do {
h = a % b;
i = c % d;
a = b;
c = d;
b = h;
d = i;
} while (h != 0 && i != 0);
}
The method of tossing and dividing is used to ensure that the numerator and denominator are mutually prime, thereby ensuring the
true fraction
- Class Diagram:
Pair evaluation:
- Although they both have pilots and pilots, they only cooperate in certain aspects. Personal coding style and code are not commented, so sometimes they cannot understand what their partners write. Each purpose can be achieved independently, but there is no connection for the time being. into a whole.
PSP:
PSP2.1 | Personal Software Process Stages | Estimated time (minutes) | Actual time (minutes) |
---|---|---|---|
Planning | plan | 60 | 60 |
Estimate | Estimate how long this task will take | 100 | 100 |
Development | develop | 800 | |
Analysis | Requirements analysis (including learning new technologies) | 100 | 60 |
Coding Standard | Code Specifications (to develop appropriate specifications for current development) | 30 | 20 |
Design UML | Design project UML class diagram | 50 | 30 |
Coding | specific code | 30 | |
Code Review | code review | 50 | |
Test | Testing (self-testing, modifying code, committing changes) | 30 | |
Size Measurement | Computational workload (actual time | 30 | |
Postmortem & Process Improvement Plan | Post-event summary, and propose a process improvement plan | 30 | |
total | 1240 |