20172311 "Java Programming" course pair programming exercises _ Arithmetic first-week phase summary pair Partners
Demand analysis <一> Functional Requirements
1. Automatic generation of topics
can be used independently (able to write the function of the test class to create a separate problem)
can generate different levels of topics, similar to:
Level 1 Title: 2 + 5 =;
10-5 =
Like two numbers, the title of an operator
2. Problem calculation (question)
can be used independently
Implement infix expression to postfix expression and calculate
Judge the user's answer correctly and output the correct result
3. Support True Score
3. Problem-solving (expansion of demand, plus sub-items)
-
Can be used independently of
-
To achieve the de-weight of auto-generated expressions:
If generated: 2 + 5 =;
5 + 2 =
for the same topic
Two > understanding of requirements 1. To have A class that generates a random topic, a number of possible points in a topic, or an integer. 2. To have a class that converts infix expressions to Postfix expressions
3. To have a class that computes a suffix expression
4. To have a class to judge the topic
5. Combine the above classes to write out the product code
the possibility of further expansion Specific topics to re-think the idea has not been produced The problem should be small.
Design Ideas
-
NML class diagram
-
Idea:
to have a class that can generate a random fraction, and apply it to classes that generate random topics, and the numbers and operators in the generated topic To have a space character, it is convenient to use the stack when converting to a suffix expression. Finally, the interaction is to let the customer answer the question, then the system to determine whether the correct and tell the customer.
related procedures
-
Generate classes of randomly minimal fractions fraction
public class Fraction {int numerator, denominator; Public fraction () {numerator= (int) (Math.random () *51); denominator= (int) (Math.random () *51); if (denominator==0) denominator=1; Reduce (); } public void reduce () {if (numerator! = 0) {int common = GCD (Math.Abs (numerator), denominator); numerator = Numerator/common; denominator = Denominator/common; }} private int gcd (int num1, int num2) {while (num1! = num2) if (Num1 > Num2) NUM1 = num1-num2; else num2 = NUM2-NUM1; return NUM1; } public string Getfraction () {string result; if (numerator==0) result= "0"; else if (denominator==1) result=numerator+ ""; else result=numerator+ "/" +denominator; return result; }}
- class that generates the corresponding number of expressions
Create
public class Create {string[]arraylist; int num,rate; public Create (int num, int. rate) {this.num=num; This.rate=rate; Arraylist=new String[num]; Public String questionrate (int a) {String express= ""; string[]oc={"+", "-", "X", "÷"}; for (int c=0;c<a;c++) {fraction b = new fraction (); String d=b.getfraction (); String e=oc[(int) (Math.random () * 4)]; while (d== "0" &&e== "÷") {fraction f=new fraction (); D = f.getfraction (); } Express +=d+ "+e+" "; } fraction c=new fraction (); String e=c.getfraction (); while (Express.charat (4*rate-1) = = ' ÷ ' &&e== ' 0 ") {fraction d=new fraction (); E=d.getfraction (); } express+=e+ "" + "="; Return Express; } public void Questionnum () {Create f=new Create (num,rate); for (int a=0;a<num;a++) arraylist[a]=f.questionrate (rate); } public string[] Getarraylist () {return Arraylist; Public String getArraylist2 (int a) {string B; B=arraylist[a]; return b; The public String toString () {string A= ""; for (int b=0;b<num;b++) a+=arraylist[b]+ "\ n"; return A; }}
- Test class
CreateTest
Run
Difficulties encountered and their solutions
- A logic error occurred while writing the class that generated the problem for the integer type, resulting in a cross-border when running the test class.
The error code is as follows:
The test class runs the following results:
The following code has been changed:
Error Analysis: The area marked by the red circle in the fault code is the error, and the statement creates an empty array that violates the intent to create an array that holds num string expressions. Thus the phenomenon of cross-border appears. After the code is changed in the constructor of the array is instantiated, and then to achieve the purpose.
Make a comment on a pair of small partners
Knot pair small partner Steven Uptown Children's shoes is the advantage of being able to listen to some of my ideas, but also to my ideas to put forward their own suggestions, and he is very patient, helpful, he will be active to help me when I knock on the code is tired of the relay. The downside might be that you're not demanding enough when you write your code, and sometimes there are some typos. On the whole, with Steven Uptown children's shoes knot pair learning is very happy, hope in the next pair of programming projects to build up and progress together!!
PSP Time Statistics
PSP2.1 |
Personal software Process Stages |
Estimated time-consuming (minutes) |
actual time elapsed (minutes) |
Planning |
Plan |
60 |
70 |
Estimate |
Estimate how long this task will take |
30 |
30 |
Development |
Development |
600 |
|
Analysis |
Demand analysis (including learning new technologies) |
120 |
180 |
Coding Standard |
Code specification (to develop appropriate specifications for current development) |
30 |
20 |
Design UML |
Design Project UML class diagram |
60 |
90 |
Coding |
Specific code |
180 |
|
Code Review |
Code review |
180 |
|
Test |
Test (self-test, modify code, commit changes) |
120 |
|
Size Measurement |
Calculation effort (Actual time |
30 |
|
Postmortem & Process Improvement Plan |
Summarize afterwards and propose process improvement plan |
|
|
|
Total |
1410 |
|
20172311 "Java Programming" course pair programming exercises _ Arithmetic first-week phase summary