### 20165219 2017-2018-2 "Java Programming" Pair Programming I and Second Week Summary

20165219 2017-2018-2 "Java Programming" Pair Programming I Summary of the Second Week

paired object

20165219 Wang Yanbo

20165232 He Yanda

demand analysis

Implement a program that requires:

1 supports integer arithmetic

2 supports multi-operator operations

3 Support fraction operation, support true fraction operation

3 Statistical accuracy

Expansion requirements:

1 Process the generated questions and output to a file

2 After completing the question, read in from the file and judge the question

3 Multi-language support: Simplified Chinese, Traditional Chinese, English

4 Generate topic deduplication

Design ideas

This is a program that needs to support complex operations. It is different from the simple four operations of a single operator. It needs to design multiple classes to implement operations, such as addition, subtraction, multiplication and division, and square operations.

nml diagram (section)

the first week

the second week

code progress

Integer class (first week)


public class IntNumber {
    private int A;

    public int getA(){
        return A;
    }

    public IntNumber(int A){
        this.A = A;
    }

    public int add(IntNumber op1){
        int sum = A + op1.A;
        System.out.print(A + " + " + op1.A + "=");
        return sum;
    }

    public int subtract(IntNumber op1){
        int num = A - op1.A;
        System.out.print(A + " - " + op1.A + "=");
        return num;
    }

    public int multiply(IntNumber op1){
        int num = A * op1.A;
        System.out.print(A + " * " + op1.A + "=");
        return num;
    }

    public static IntNumber obj(){
        Random ran = new Random();
        return new IntNumber(ran.nextInt(20)-10);
    }

    public String divide(Score op1){
        System.out.print(op1.getNumerator() + " / " + op1.getDenominator() + "=");
        return op1.toString();
    }
}

Code cloud hosting

Score class:

Code cloud link

True or false judgment

Code cloud link

Main class NumberCount

Code cloud link

Functional screenshot

Tests for Normal Boundary Anomalies


pair feeling

Based on two weeks of pair programming, we feel that designing four arithmetic operations through looping statements is simple in thinking, but also has many shortcomings. At present, it is a shortcoming that it cannot support multi-level operations. At the same time, the code of the fractional calculation also consulted the help of the classmates, and the code of the unit test class was not completed. In general, I have gained something. I believe that in the future study, we can give full play to the help of pair programming ideas for learning.

Guess you like

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