20172310 "Program Design and Data Structure" Experiment 2 Report

20172310 2017-2018-2 "Program Design and Data Structure" Experiment 2 Report

Course: "Program Design and Data Structure"
Class: 1723
Name: Qiu Xia
Student ID: 20172310
Experiment Teacher: Wang Zhiqiang
Experiment Date: April 21, 2018
Compulsory/Elective: Compulsory

Experimental content

Require

  • Getting started with unit testing and TDD
  • Understand and master the three elements of object-oriented: encapsulation, inheritance, polymorphism
  • Preliminary mastery of UML modeling
  • Become familiar with SOLID principles
  • Learn about design patterns
  • Complete the (1)-(5) experiments on the blue ink cloud

    Specific content:

  • understand the above concepts.
  • Learned to use junit test code on IDEA, and learned some rules of test class.
  • Two class diagrams are drawn using WhiteStarUML.

Experimental process and results

  • The first submission point is to learn and understand unit testing (programmers test class implementation is called unit testing); recognize three types of codes in programming: pseudo code, product code, test code, and realize that pseudo code is the most natural product code , the best note; experimental content, we have written three kinds of tests, namely: test normal, test abnormal, test boundary.
    Experiment 2 Object-Oriented Programming (1) Link

  • The second submission point is to study and learn StringBuffer in the way of TDD. The development method of writing test code first, and then writing product code is called "test-driven development" (TDD).
    Experiment 2 Object-Oriented Programming (2) link

  • The third submission point is to expand the design pattern example, experience the application of the OCP principle and the DIP principle, perform the remainder operation on your own student number %6, and expand the code according to the result.

    And the output values ​​are all 4, and there is no difference between doubles. I will give the modified ones below.

  • The fourth commit point is to develop a complex class Complex in a TDD manner.
    Experiment 2 Object-Oriented Programming (4)
  • The fifth commit point , modeling the code in Experiment 2.
    Experiment 2 Object-Oriented Programming (5)
    • In fact, the textbook has mentioned the drawing method of class diagrams many times, but I thought it was not very important at the time, because we can also express our ideas on paper, so I didn’t pay much attention to the drawing rules of class diagrams
      until I tried to draw it myself. Class diagram, only to find that the class diagram does not look easy to draw, but in fact it is very useful to master certain rules.

Problems encountered during the experiment and the solution process

  • Question 1: How is the indexOf method used?

Why System.out.println(buffer.indexOf("tring12345"));is the displayed value -1? doesn't t appear in the string?

  • Problem 1 solution:

Although tring12345t appears in the second position, his print value is -1 instead of 1, because 12345 is a value that does not appear in the string. In this case, it
will also be considered non-existent, so it is -1.

  • Question 2: How to change the fourth of experiment 2? This is my modified code later
  • Problem 2 solution:

Other (perception, thinking, etc.)

Now that you have acquired knowledge, you must know how to use it. However, experimentation is indeed a difficult part of Java learning.
I always feel that knowledge is simply stored in the brain (not even in the brain), but it is very difficult to use it.
When I faced this experimental question, I had no clue, and I was very impatient. Therefore, you
still have to calmly try to complete it, and don't be afraid of making mistakes.

References

Guess you like

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