Experiment two Java object-oriented programming

Source: Internet
Author: User

First, the purpose of the experiment

1. Initial mastery of unit testing and TDD

2. Understanding and mastering the object-oriented three elements: encapsulation, inheritance, polymorphism

3. Initial mastery of UML modeling

4. Familiarity with S.O.L.I.D principles

5. Understanding Design Patterns

Ii. contents of the experiment

(a) Unit testing

Pseudo-code: independent of the specific programming language, is the most natural product code, the best comment.

Product Code

Test code

Experimental steps:

In a myutil class to solve a percentile score into "excellent, good, medium, pass, fail" five Grade system performance function

The first step: write the percentile five-point pseudo-code as follows:

If the score is less than 60, turn into "fail"

If the score is between 60 and 70, turn into "pass"

If the score is between 70 and 80, turn into "medium"

If the score is between 80 and 90, turn into "good"

If the score is between 90 and 100, turn into "good"

Other, turn into "error"

The second step: write the test code (including test boundary values and exceptions) as follows:

The third step: write the product code as follows:

Run it and if you find that the error improves the product code according to the error, the operation succeeds.

From the above, the TDD method has successfully implemented the product code

Experiment two Java object-oriented 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.