20172330 2017-2018-1 "Java Programming" eighth week study summary

Student number 2017-2018-1 "Program Design and Data Structure" Week 8 Learning Summary

Textbook learning content summary

This chapter is mainly about polymorphism:

Polymorphism through inheritance

  • Polymorphic references can point to different types of objects over time.
  • For polymorphic references, the binding of the method call to the method definition code is performed at runtime.
  • A reference variable can point to any object of any class that has an inheritance relationship.
  • The actual version of the method that will be called depends on the type of the object and not the type of the reference variable.
  • The essence of polymorphism is that each class knows how to accomplish a given behavior, and in a sense, each class behaves the same, polymorphism allows a consistent but unique way to deal with similar objects.

    Implementing polymorphism with multiple ports using interfaces

  • Interface names can declare object reference variables.
  • An interface reference variable can point to any object of any class that implements the interface.
  • The parameters of a method can be polymorphic, allowing flexibility in the parameters the method accepts.
  • A sorting algorithm implemented polymorphically can sort any set of comparable objects.
  • Learn to use sorting and insertion.
  • Polymorphism allows inconsistent behavior to be achieved in a consistent way.
  • Learn to use linear search and binary search.

Problems and Solving Processes in Teaching Materials Learning

  • Question 1: Comparison of Sorting Algorithms
  • Solution to Problem 1: As the book says, selection sorting and insertion sorting have substantially the same efficiency. However, the selection method sorting is easy to understand, can meet the needs in most cases, and each value is accurately moved to its final position at one time, so it is better than the insertion method.

Specific examples are as follows:
```Use selection and insertion sort, write the result of the third sorting: 3 1 9 3 6 2 10
Selection sort:
1 2 3 9 6 3 10

Insertion sort:
1 3 3 9 6 2 10.
````

  • Problem 2: Search when comparing methods
  • Solution to problem 2: As far as the search method is concerned, the binary method is far more efficient than the linear search, but the binary search requires that the data is already sorted.
    If the data sorting is relatively easy or the search volume of the data is very large, binary search is more appropriate, but the implementation of linear search is quite simple, and if the long-term efficiency of the detention center is not an important issue, linear search may be the best choice.
    Linear search can be used for any array. After traversing each item in the array in turn, it is compared with the item to be searched.
    The consumption time is also irregular, and the search item may be in the first position of the array, or it may be in the last position of the array. It is also possible that the item to be looked up is not present in the array at all.

The binary search method is used for sorted arrays.
Because the array has been arranged in order, you can divide the array from the middle to compare the middle item with the desired search item; then, according to the comparison result, go up or down again to find the middle item for comparison until the search is completed.
Also, for the beginning of the lookup, you can determine whether the lookup item is in this array by comparing it with the first item and the last item.

Problems and solutions in code debugging

  • Question 1: When defining the MonetaryCoin class, the int type was used in the definition because of the face value of the coin. Later, because of the existence of 0.5, there was a problem.
  • Problem 1 solution: Problem solved after I modified the definition

code hosting

Summary of last week's exam mistakes

  • 1.All classes in Java are directly or indirectly subclasses of the ________ class.
    A Wrapper
    B String
    C Reference
    D this
    E Object
    Analysis: Java requires that all classes have parent classes. If a class does not extend another class then it extends the object class by default. An object class is the parent or parent class of other classes in Java. So obiect is the parent class of other classes.

Pairing and mutual evaluation

Review Template:

  • Worth learning or questions from the blog:
    • Pictures and text are combined for easy understanding.
    • The directory in the blog has been added for easy viewing, and the style has been updated to make it more beautiful
    • Read a lot of material to make the blog more persuasive.
  • Worth learning or problems in the code:
    • The two of us were doing the four calculations this week, and Yan Yujun spent a lot of time writing the output of the topic, and he and I also discussed many methods of writing classes. We will continue to strengthen this cooperative attitude in the future.
    • The commit is still very detailed and organized.

Reviewed classmates blog and code

  • Pair study this week
    • 20172333
    • Pair learning content
      • Study Chapter 10 pp projects.
      • Learn the specifics of inheritance
      • A project to do four arithmetic operations together.

Others (perception, thinking, etc., optional)

This week, I didn't have much problem doing the after-school project, but I encountered a lot of problems when I was writing the four arithmetic operations, and I need to continue to study hard.

learning progress bar

Lines of code (added/accumulated) Blog volume (new/cumulative) Study time (added/accumulated) important growth
Target 5000 lines 30 articles 400 hours
the first week 180/180 2/2 20/25
the second week 312/414 2/4 20/45
The third week 557/971 1/5 25/70
the fourth week 1217/2242 2/7 44/114
fifth week 734/2976 1/8 24/138
Week 6 523/3509 1/9 20/158
Week 7 697/4206 1/10 24/182
eighth week 697/4206 3/113 30/212

Reference: Why is the estimation of software engineering software so difficult , software engineering estimation methods

  • Planned study time: 20 hours

  • Actual study time: 24 hours

  • Improvements:

This week, the after-class exercises are not so difficult, but there are still some problems with the writing of the class. I hope to continue to work hard.

References

Guess you like

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