Java Lab report (Experiment II)

Source: Internet
Author: User

Beijing Institute of Electronic Technology

Real Inspection report

Course: Mobile Platform Application development Practice class: 201592 Name: Souzenan No.: 20159207

Score: Instructor: Lou Jia Peng Experimental Date: 2015.10.5

Experiment level: Preview degree: Experiment time:

Instrument Group: Compulsory/Elective: Elective experiment number: 2

Experiment Name: Java Object-oriented programming

Experimental Purpose:

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

Experimental requirements:

1. Learn about the basics of Linux (new version), VIM editor Course

2. Complete the experiment, write the experiment Report, the experiment report is published in the blog garden

3. No plagiarism, there is zero test results of the perpetrators, and additional punitive measures

4. In the ~/code directory with their own school number to create a directory, code and UML diagram to be placed in this directory, no study number will require redo, and then follow the following steps to practice.

Laboratory Equipment:

Name

Model

Number

Computer

X230

1

Experimental content:

(a) Unit testing

Pseudo-code (not syntax-related, mainly to illustrate the main function of the product)

Product Code (code required by a product and implemented in a language)

Test code (mainly used to test the product can be online, through the boundary value, domain, available values, etc. test to verify the product)

Here's what I'll show you about this experiment:

We should solve a percentile grade in Myutil class to turn into "excellent, good, medium, pass, fail" five grade system performance function.

First, according to Lou Teacher's request, I show my folder path:

The first step: write 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 as follows:

The third step: write the product code as follows:

Run, find errors, improve the product code based on errors,

The improved code is as follows: Run successfully

Fourth step: Test boundary values and exceptions as follows:

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

Next, I'll demonstrate the three elements of object-oriented: encapsulation, inheritance, polymorphism:

First of all, I downloaded the STARTUML software, it is a modeling software, can draw UML (Unified Modeling Language) diagram, I understand the abstraction and encapsulation is: for example, you and I are human, we can abstract that we belong to human, in fact, human is an abstract class, Encapsulation is the encapsulation of human properties (we all have arms, legs, noses, etc.) in the human category.

Next is inheritance: Both dog and cat inherit the attributes of animal:

As above, a reference is declared with the parent class, and the object is generated with a subclass, which is polymorphic.

Exercise: Use TDD to design and implement the plural class complex.

Or with the method above,

The first step: write the pseudo-code:

If there is no input, the real part of the complex number is 0 and the imaginary part is 0
If you enter only the real part, the real part of the plural is the number of inputs and the imaginary part is 0
If only the imaginary part is entered, the real part of the complex number is 0 and the imaginary part is the input
If both the real and imaginary parts are entered, the real and imaginary parts of the complex numbers are the corresponding input values

The second step: write the test code, according to the test situation to write the product code:

Steps

Take

Percentage

Demand analysis

6min

15.4%

Design

12min

30.8%

Code implementation

10min

25.6%

Test

7min

17.9%

Analysis Summary

4min

10.3%

The benefits of unit testing:

1: In the test of the project, the edge of the writing, you can design the project continuously optimized;

2: Unit test is carried out according to the module, which helps to realize the module "high cohesion within the block, low coupling between the blocks ";

3: For the follow-up testing to lay the foundation, unit testing is done, the subsequent testing efficiency will be improved.

Summarize

problems encountered in this experiment:

In the use of myeclipse, according to Animaltest.java to modify Animal.java, but modified for a long time, Animaltest.java appeared again

Error.

Workaround: I will close the MyEclipse, then open again, all the files ctrl+s, the result of the error disappears.

Analysis Reason: Write the code must ctrl+s, otherwise cannot implement the file association, some methods can not be called.

Java Lab report (Experiment II)

Related Article

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.