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上花费了暴多时间。另外,在动车上敲代码的感受很不错_(:з」∠)_

参考资料

相关文章
相关标签/搜索