20182301 2019-2020-1 "Object-oriented programming and data structures" Experimental Report 3

20182301 2019-2020-1 "Object-oriented programming and data structures" Experimental Report 3

Course: "Programming and Data Structures"
Class: 1823
Name: Zhao Pei Ning
Student ID: 20182301
experiments Teacher: Johnny
experiment Date: September 23, 2019
Compulsory / Elective: Compulsory

1. Experimental content

Download and install and use the IDEA, following the completion of the experiment ( https://www.cnblogs.com/rocedu/p/6371315.html ).

  1. Initial grasp of unit testing and TDD

  2. Understand and master the object-oriented three elements: (! Own to learn) encapsulation, inheritance, polymorphism

  3. Preliminary master UML modeling

  4. On completion of the cloud blue ink (1) - (5) experiments.

2. Experimental procedure and results

First

  1. Writing Product code MyUtil.java
  2. Writing test code MyUtilTest.java
    1. project -> (right) new -> Directory
    2. test ——>(右键) make directory as ——> Test Source Root
  3. TDD use
    1. File ——>settings ——>plugins ——>junit
    2. Small bulbs creat test
    3. File ——>Project Strsture
  4. testing successfully

the second

  1. Manual play StringBuffer, several methods should experiment with them, and to distinguish the differences between StringBuilder, StringBuffer, String class
  2. The method of learning equals, modify the error code (tupianequals on page :)
  3. Writing the test code according to the above method
  4. testing successfully


The third

  1. SOLID principles of learning

the fourth

  1. In UML good design, ease of code smoothly
  2. Constructor initializes the data
  3. The use of two numbers encapsulated getX
  4. Product code writing and testing code
  5. testing successfully

3. Experimental problems encountered in the process and settlement process

  • Question 1: StringBuffer methods do not expand capacity in space (the blog screenshots wrong, believe in yourself)

  • Problem 1 Solution :( teacher thinking questions made me understand its use)
  •   public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("cccccccccccc");
    System.out.println("sb:" + sb);
    System.out.println("sb.capacity():" + sb.capacity());
    System.out.println("sb.length():" + sb.length());
    
    StringBuffer sBuffer =new StringBuffer();
    sBuffer.append("cccccccccccc");//12个c
    System.out.println("SBuffer's capacity"+sBuffer.capacity());
    
    }
    }
    Why the different results?
    Both methods are not the same store, the last space storage methods are not the same.
  • Problems 2: java prepared complex class code arithmetic multiplication, division problems

  • Problem 2 Solution: a complex class of simple addition and subtraction, multiplication and division to think about: not just use two variables is solved, require multiple auxiliary variables.

Other (perception, thinking, etc.)

The code is now gradually increase the difficulty, if not seriously study and understand thoroughly, it is prone unable to write phenomenon. I should actively take the initiative to learn, to root out some knowledge, and finally succeed. On the blog may be wrong, there is evidence in the case, I believe in yourself!

Reference material

Guess you like

Origin www.cnblogs.com/zhaopeining/p/11599723.html