CSC207.01 2014F, Class 06: Classes and Objects
- Upcoming Work.
- Extra Credit.
- A brief introduction to objects.
- I brought you food. I hope you brought me surveys.
- A few of you have asked that we use IntelliJ instead of Eclipse. If
you really want me to switch, we have to figure out the following:
- I'll need you to build me a code preferences file that matches my
code conventions. (I'm willing to vary a bit, but not too much.)
- You need to find a way to make sure that it is a reasonable user of
our file system.
- HW 3 due Tuesday.
- About half of you haven't done the prologue, which worries me
- Worries about part C? ("the wording is confusing")
- Normal object-design questions:
- What data will I need to store?
- What methods will I provide to access/manipulate those data?
- How should I represent a time?
- Talk about it in the abstract. "time: a time"
- Create your own class.
Fields: day, week, year, hour
Constructor: UshahiTimestamp(day, week, year, hour)
* Look at Java reference
* Shallow or deep analysis of Web site?
* Focus on the main objects you think you'll need
for representing the underlying data.
* Finding methods: Eclipse and the API pages should be useful
* For Part A's testing, can we just be thorough with individual tests,
rather than writing a for loop?
* Often, you want both.
* Individual tests for corner cases.
* Loops to ensure you check a broad range of values.
* How should we approach the "average doesn't work on all values"
* There's an implicit hint in part A.
* Think about special cases from your own work in C.
* The bug was found by someone at Google when they were working
with the built-in binary search in Java.
* Do we have to fix the code for real, or can we just specify
* You should fix the code so that it works for any pair
* Do you want us to document classes and methods?
* Simple "this is what it does" documentation is nice, preferably
* Daily lab writeup: http://bit.ly/207writeup
* Reading for Tuesday:
* Arrays in Java
Extra Credit Opportunities
- I haven't seen many responses yet. EC is a good and easy way to earn
a few more points for the course.
- Convo next Wednesday at noon. "Limiting Armed Drone Proliferation" by
Micah Zenko, the Douglas Dillon fellow in the Center for Preventive
Action at the Council on Foreign Relations and vice chair of the World
Economic Forum Global Agenda Council on Terrorism.
- Sam's comments on the value of convo
- Any other event in the Rosenfield Drones program.
- CS Extra, Thursday, September 11: Ajuna Kyaruzi '17 on being a SysAdmin
- CS Table, Friday, September 12: Socially-Assistive Robots Help Children with Autism
- Men's Soccer (Wednesday at 5pm)
- Second-year students get extra credit for doing the second-year science
retreat on Sept. 20.
A brief introduction to objects
- What did you learn from the reading?
- Objects are specified with templates, which have three components:
Fields, methods, and constructors
How do I declare a field? Type and name
Fields might also have a modifier
- Protection level: private, public, protected, (nothing)
static - "It's own thing". "You can use it without creating
final - constant
How do I declare a constructor?
- The name of the constructor matches the name of the type
- No return value, no static, but may have protection level
- Parameters can be used to initialize fields