20172303 2017-2018-2 《程序設計與數據結構》第5周學習總結

20172303 2017-2018-2 《程序設計與數據結構》第5周學習總結

教材學習內容總結

  • 第五章
    • 控制程序執行流程的語句分爲兩類:條件語句(又稱爲選擇語句)和循環語句。
    • 相等性、關係和邏輯運算符的運用
    • if語句(條件語句),可以使用語句塊,可嵌套。
      • 格式:if(布爾表達式){一條或一組語句}
    • if-else語句。
      • 格式:if(布爾表達式){一條或一組語句} else{一條或一組語句}
      • else會與它最前面未匹配的if語句匹配。
    • while語句(循環語句),可嵌套,能完成無限循環。
    • 數據比較。主要講了浮點數比較和字符串比較兩部分。
      • 格式:while(布爾表達式){語句或語句塊}
    • break和contin語句。
      • break語句的做用可簡述爲「跳出」循環。
      • continue語句的做用與break類似,但若循環再次進行,布爾值爲true時仍會繼續進行循環。
    • 迭代器和ArrayList類,大概看懂書上的內容,應用感受還不是很會。
  • 第六章
    • switch語句。
      • 格式:switch(布爾表達式){case 1;break;case2 break;...default}
      • break和default都不是必需要有的。
      • 表達式的運算結果必須是char、byte、short、int或String型。
    • 條件運算符。
      • 格式:(布爾條件?表達式:表達式)
      • 可讀性不如if-else語句,做用上與之類似。
    • do語句(循環語句)。
      • 格式:do{語句或語句塊}while(布爾表達式)
      • 與while語句做用類似,不一樣點在於do語句至少執行一次。
    • for語句(循環語句)。
      • 格式:for(初始化;布爾表達式;增量部分){語句}
      • 增量部分既可遞增也可遞減。
      • 與前兩個循環語句做用類似,建議在知道具體循環次數時使用。

教材學習中的問題和解決過程

  • 問題1:第五章自測題SR5.11的a作的時候結果與答案不符
  • 問題1解決方案:本身把代碼敲出來運行了一下,結果仍然與答案不符,答疑以後肯定是答案錯誤。
  • 問題2:作例5.9時不清楚another.equalsIgnoreCase("y")是幹嗎的
  • 問題2解決方案:查書第76頁String類提供的一些方法中說該方法的用法是「若是本對象字符串與str對象字符串相同(不區分大小寫),返回真,不然返回假。」
  • 問題3:第五章自測題SR5.29作出來又與答案不符_(:з」∠)_
  • 問題3解決方案:再把前面的內容看了一遍發現是本身看書太粗糙,主要錯過的兩個要點是:1.ArrayList的索引值從0開始。2.remove方法的做用是刪除列表指定索引處那個元素並【返回】它。

代碼調試中的問題和解決過程

  • 問題1:git push失敗,讓先git pull,而git pull又發生錯誤(很遺憾這裏忘記截圖了...)
  • 問題1解決方案:先把以前的東西備份了一份,嘗試了不少次以後選擇從新建一個directory,使用git clone把碼雲上的東西從新弄回來,新的可使用git push但舊的仍是不行_(:з」∠)_ 不過沒多大問題就是新的目錄裏的代碼量又從0開始統計了...解決的方法是每次在這個新目錄裏編輯完以後所有複製到舊目錄裏來統計代碼量_(:з」∠)_
  • 問題2:PP5.7最後輸贏和平局的統計結果老是不對
  • 問題2解決方案:詢問了張昊然同窗後知道了是由於if語句後沒把那些表達式歸到一個語句塊裏,致使「++」不論什麼狀況都會運行。以前的修改過的

代碼託管


commit截圖
php

上週考試錯題總結

  • 錯題1:The relationship between a class and an object is best described as
    • A . classes are instances of objects
    • B . objects are instances of classes
    • C . objects and classes are the same thing
    • D . classes are programs while objects are variables
    • E . objects are the instance data of classes
  • 緣由及理解狀況:一詞之差,「實例」和「實例數據」,實例被稱爲對象,而實例數據...我在網上根本查不到這個東西_(:з」∠)_
  • 錯題2: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
  • 緣由及理解狀況:final與分裝無關。
  • 錯題3:If a method does not have a return statement, then
    • A . it will produce a syntax error when compiled
    • B . it must be a void method
    • C . it can not be called from outside the class that defined the method
    • D . it must be defined to be a public method
    • E . it must be an int, double, float or String method
  • 緣由及理解狀況:沒有返回值時必定要用void
  • 錯題4:Consider a Rational class designed to represent rational numbers as a pair of int's, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two int's), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private.
    • A . Because they will never be used
    • B . Because they will only be called from methods inside of Rational
    • C . Because they will only be called from the constructor of Rational
    • D . Because they do not use any of Rational's instance data
    • E . Because it is a typo and they should be declared as public
  • 緣由及理解狀況:聲明爲私有的類的全部項只能由該類中的實體訪問,不管它們是實例數據仍是方法。
  • 錯題5:What happens if you declare a class constructor to have a void return type?
    • A . You'll likely receive a syntax error
    • B . The program will compile with a warning, but you'll get a runtime error
    • C . There's nothing wrong with declaring a constructor to be void
    • D . The class' default constructor will be used instead of the one you're declaring
    • E . None of the above
  • 緣由及理解狀況:之後要改掉這個稍微看不懂題,看到E選項是個總結性的就選它的毛病。本題網頁上的答案是錯的,正確答案是D,構造函數沒有void,加了以後會變成普通方法。
  • 錯題6:Every class definition must include a constructor.
    • A . true
    • B . false
  • 緣由及理解狀況:本題意思是必須編譯一個,但在編譯時系統會自動產生一個空的構造函數。
  • 錯題7:Static methods cannot
    • A . reference instance data
    • B . reference non-static instance data
    • C . reference other objects
    • D . invoke other static methods
    • E . invoke non-static methods
  • 緣由及理解狀況:實例數據中包含靜態和非靜態的,只能引用靜態的,非靜態的必須聲明(new)以後才能用。
  • 錯題8:Inheritance through an extended (derived) class supports which of the following concepts?
    • A . interfaces
    • B . modulary
    • C . information hiding
    • D . code reuse
    • E . correctness
  • 緣由及理解狀況:概念性問題。
  • 錯題9:The goal of testing is to
    • A . ensure that the software has no errors
    • B . find syntax errors
    • C . find logical and run-time errors
    • D . evaluate how well the software meets the original requirements
    • E . give out-of-work programmers something to do
  • 緣由及理解狀況:當時看的時候英語理解有問題。軟件測試的做用在書上第194頁。
  • 錯題10:Interface classes cannot be extended but classes that implement interfaces can be extended.
    • A . true
    • B . false
  • 緣由及理解狀況:對於接口,能夠繼承,一個類能夠繼承多個接口,不論類是否擴展都能繼承。

其餘(感悟、思考等,可選)

  • 首先這星期最大的一個感悟就是作課後自測題真的很是很是重要!之前基本都是一晃而過或者作的不多_(:з」∠)_但本週認真作的時候發現不少問題都是在作自測題的時候發現的,而且作自測題真的是對前面知識掌握程度的一個很是好的考覈。除此以外,感受本身越日後學前面忘得越多,因此我決定從這周開始從新從第一章開始看課本,計劃從下週開始在博客中記錄從新看課本的進度。

學習進度條

代碼行數(新增/累積) 博客量(新增/累積) 學習時間(新增/累積) 重要成長
目標 5000行 30篇 400小時
第一週 120/120 1/1 9/9
第二週 246/366 1/2 9/18
第三週 785/1121 2/4 15/33
第四周 615/1736 1/5 20/53
第五週 1409/2645 1/6 24/77
  • 計劃學習時間:18小時
  • 實際學習時間:24小時
  • 改進狀況:原本看着這周內容少以爲花的時間不會多,沒想到在PP5.3和PP5.7上花費了暴多時間。另外,在動車上敲代碼的感受很不錯_(:з」∠)_

參考資料

相關文章
相關標籤/搜索