20182304 2019-2020-1 《數據結構與面向對象程序設計》第四周學習總結
教材學習內容總結
代碼調試中的問題和解決過程
- 問題1:誤在get方法中傳參致使程序錯誤
- 問題1解決方案:經過同窗的幫助,瞭解到get方法中不能傳入參數,只能返回數據。傳參應該在其它方法如set中完成
問題2:在敲書上的Coin類時,一行代碼count1 = (coin1.isHeads()) ? count1+1 : 0;
我將count1+1
敲成了count++
,原本覺得區別不大,程序運行時卻形成了死循環

api
- 問題2解決方案:
count++
與count=count+1
等價,count自己被該變了。由於上式中等式左邊有count=,因此形成了死循環。而count+1不改變count的值,因此在賦值語句中能夠正常使用
- 問題3:git配置好後沒法正常上傳
問題3解決方案:沒有看清 push 後再提交,默認的是commit,須要本身手動設置一下安全
(
數據結構
)app
上週考試錯題總結
- What is the function of the dot operator?
- A .It serves to separate the integer portion from the fractional portion of a floating point number
- B .It allows one to access the data within an object when given a reference to the object
- C .It allows one to invoke a method within an object when given a reference to the object
- D .It is used to terminate commands (much as a period terminates a sentence in English)
- E .Both B and C are correct
- The dot operator is appended directly after the object reference, followed by the data or method to which access is desired. In the case of data, the access may be for reading or writing. In the case of a method, the access is to allow one to invoke the method. The dot within a floating point number is a decimal point not a dot operator.
- 理解:點運算符能夠直接加在對象引用以後,而後加上要調用的方法名,也能夠在給定對象的引用時訪問對象中的數據。。
- The String class' compareTo method
- A .compares two string in a case-independent manner
- B .yields true or false
- C .yields 0 if the two strings are identical
- D .returns 1 if the first string comes lexically before the second string
- E .none of the above
- 理解:identical爲相等,沒有理解英文含義致使錯誤。compareTo與C中的用法類似
- The names of the wrapper classes are just the names of the primitive data types, but with an initial capital letter.
- A .true
- B .false
- This is true for most of the wrapper classes, but it is false for int (Integer) and char (Character).
- 理解:翻閱圖書,可查到int的包裝類爲Integer,char的包裝類是Character,其它類型包裝類爲首字母大寫
- The advantage(s) of the Random class' pseudo-random number generators, compared to the Math.random method, is that
- A .you may create several random number generators
- B .the generators in Random are more efficient than the one in Math.random
- C .you can generate random ints, floats, and ints within a range
- D .you can initialize and reinitialize Random generators
- E .all but answer B
- The efficiency of all the random number generators are the same. The advantages of Random generators over Math.random include all the other properties.
- 理解:效率是同樣的
- These two ways of setting up a String yield identical results:
- a) String string = new String("123.45"); b) String string = "" + 123.45;
- A .true
- B .false
- 理解:""也是字符串,+能夠自動鏈接字符串,這樣後面的數字也以字符串的形式被賦給了string,二者等價
- In order to preserve encapsulation of an object, we would do all of the following except for which one?
- A .Make the instance data private
- B .Define the methods in the class to access and manipulate the instance data
- C .Make the methods of the class public
- D .Make the class final
- E .All of the above preserve encapsulation
- Encapsulation means that the class contains both the data and the methods needed to manipulate the data. In order to preserve encapsulation properly, the instance data should not be directly accessible from outside of the classes, so the instance data are made private and methods are defined to access and manipulate the instance data. Further, the methods to access and manipulate the instance data are made public so that other classes can use the object. The reserved word "final" is used to control inheritance and has nothing to do with encapsulation.
- 理解 :D必定是錯誤的,若是把類設置成final,它就不能被重寫,子類一直都會是抽象類,不能實例化
- Having multiple class methods of the same name where each method has a different number of or type of parameters is known as
- A .encapsulation
- B .information hiding
- C .tokenizing
- D .importing
- E .method overloading
- When methods share the same name, they are said to be overloaded. The number and type of parameters passed in the message provides the information by which the proper method is called.
- 理解:錯誤緣由是由於對書中類型知識點理解不足
- Visibility modifiers include
- Public, private, protected control the visibility of variables and methods. Final controls whether a variable, method, or class can be further changed or overridden not visibility. Static controls whether a variable or method is associated with instances of a class or the class itself.
- The following method header definition will result in a syntax error: public void aMethod( );
- A .true
- B .false
- The reason for the syntax error is because it ends with a ";" symbol. It instead needs to be followed by { } with 0 or more instructions inside of the brackets. An abstract method will end with a ";" but this header does not define an abstract method.
- 理解:首先,方法後不能有冒號。其次,它後面應該有一個大括號
- Every class definition must include a constructor.
- A .true
- B .false
- Java allows classes to be defined without constructors, however, there is a default constructor that is used in such a case.
- 理解:能夠不定義,它會默認生成一個構造方法
結對及互評
評分標準
- 正確使用Markdown語法(加1分):
- 不使用Markdown不加分
- 有語法錯誤的不加分(連接打不開,表格不對,列表不正確...)
- 排版混亂的不加分
- 模板中的要素齊全(加1分)
- 缺乏「教材學習中的問題和解決過程」的不加分
- 缺乏「代碼調試中的問題和解決過程」的不加分
- 代碼託管不能打開的不加分
- 缺乏「結對及互評」的不能打開的不加分
- 缺乏「上週考試錯題總結」的不能加分
- 缺乏「進度條」的不能加分
- 缺乏「參考資料」的不能加分
教材學習中的問題和解決過程, 一個問題加1分dom
代碼調試中的問題和解決過程, 一個問題加1分ide
- 本週有效代碼超過300分行的(加2分)
- 其餘加分:
- 週五前發博客的加1分
- 感想,體會不假大空的加1分
- 排版精美的加一分
- 進度條中記錄學習時間與改進狀況的加1分
- 有動手寫新代碼的加1分
- 課後選擇題有驗證的加1分
- 代碼Commit Message規範的加1分
- 錯題學習深刻的加1分
- 點評認真,能指出博客和代碼中的問題的加1分
- 結對學習狀況真實可信的加1分
- 扣分:
- 有抄襲的扣至0分
- 代碼做弊的扣至0分
- 遲交做業的扣至0分
點評模板:
點評過的同窗博客和代碼
- 本週結對學習狀況
- 20182302
- 結對學習內容
- 學習接口的概念與具體操做
- 理解類的定義與封裝
- 調試實驗程序中的編譯錯誤
- 上週博客互評狀況
其餘(感悟、思考等,可選)
- 在測試後,我發現本身只對教材有大概理解,不少知識點細節仍是陌生的,存在着很大的提高空間
- 從第五章開始,Java的學習難度是比較大的,須要花費更多時間精力學習
學習進度條
目標 |
5000行 |
30篇 |
400小時 |
|
第一週 |
200/200 |
2/2 |
20/20 |
|
第二週 |
300/500 |
2/4 |
18/38 |
|
第三週 |
500/1000 |
3/7 |
22/60 |
|
第四周 |
300/1300 |
2/9 |
35/100 |
|
嘗試一下記錄「計劃學習時間」和「實際學習時間」,到期末看看能不能改進本身的計劃能力。這個工做學習中很重要,也頗有用。
耗時估計的公式:Y=X+X/N ,Y=X-X/N,訓練次數多了,X、Y就接近了。
參考:軟件工程軟件的估計爲何這麼難,軟件工程 估計方法
計劃學習時間:40小時
實際學習時間:35小時
改進狀況:我會努力提升一些學習效率
(有空多看看現代軟件工程 課件
軟件工程師能力自我評價表)
參考資料