20165205 2017-2018-2 "Java programming" a first week summary of pair programming

Source: Internet
Author: User
Tags throw exception

20165205 2017-2018-2 "Java programming" a first-week summary of requirements analysis

The calculation of the input formula requires that the condition be met:

    1. Integer operations such as 2+5,47+7865 are supported.
    2. Supports multi-operator operations, such as 6/9+4/9,4+7*9.
    3. Supports fractional operations (true fractions), such as 3/4.
    4. High correct rate
    5. have input prompt
    6. Ability to handle illegal input (return exception)

Expansion requirements:

    1. Support automatic generation of topics
    2. Multi-lingual support

      Design ideas
    3. Writing the main classArithmetic4
    4. Write the ArithmeticFunc class to implement the calculation, including: Add, subtract, multiply, divide, Zhifang, prescribe the method, also contains the method that throws the exception.

Core code and comments
  1. To calculate the content, take the addition method as an example:

    public void Add (String s)//addition {string[] Str=s.split ("\\+");        if (Str[0].indexof ("/") >-1 | | str[1].indexof ("/") >-1)//score {string[] Str1=str[0].split ("[/]");        String[] Str2=str[1].split ("[/]"); if (Integer.parseint (str1[1])! = 0 && integer.parseint (str2[1])! = 0)//denominator not zero {result =simplefrac tion (((Integer.parseint (str1[0) *integer.parseint (str2[1]) + (Integer.parseint (str2[0]) *integer.parseint (str1[1        ])), (Integer.parseint (str1[1]) *integer.parseint (str2[1])); }else{throw new IllegalArgumentException ("Divisor cannot be zero!"); /divisor is zero throw exception}} else{//integer if (integer.parseint (str[0]) <1000&&integer.parseint (str[1]) <100 0&&integer.parseint (Str[0]) >-1000&&integer.parseint (str[1]) >-1000) {result = Inte        Ger.parseint (Str[0]) +integer.parseint (str[1]) + ""; } else{throw new IllegalArgumentException ("overrun!");} Throw exception when value range exceeds}} 
  2. Throw exception operator: Take subtraction as an example

        if(s.indexOf("-")>-1){        int i=s.indexOf("-");        if(s.indexOf("-",i+1)==i+1){            throw new IllegalArgumentException("Input error! Don‘t like 1--1");//格式错误时抛出异常        }else{            substract(s);        }
Test method

Code hosting reviews for pair of small partners
    • Pair of partners: 20165233 Zhang Yuxin
    • I've been talking to my partner for a long time. The design of the code, after learning the teacher for the stack of code to get some inspiration, so write out the first frame, the different operators to filter, and then for the different operators to do the operation, so that the completion of this code.
PSP Table
Psp Personal Software Process Stages Estimated time-consuming (minutes) Actual time elapsed (minutes)
Planning Plan 30 45
Estimate Estimate how long this task will take 180 180
Development Development 100 130
Analysis Demand analysis (including learning new technologies) 130 140
Design Spec Creating a design Document 100 65
Design Review Design Review (and colleagues review design documents) 30 20
Coding Standard Code specification (to develop appropriate specifications for current development) 20 40
Design Specific design 50 60
Coding Specific code 45 30
Code Review Code review 15 15
Reporting Report 60 90
Test Report Test report 30 45
Postmortem & Process Improvement Plan Summarize afterwards and propose process improvement plan 10 25
Total 880 985
Feelings

For this pair to write code, I feel the 1+1>2 feeling, in the process of writing code two people can timely rewrite the incorrect code, and can get new ideas, and make our code more perfect, more rigorous. At the same time also can find their own knowledge of loopholes, to supplement, really is wonderful AH.

20165205 2017-2018-2 "Java programming" a first week summary of pair programming

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.