10-07 Class Notes CS 107

10-07 Class Notes CS 107 - this as the first action in the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Announcements: Questions? From last time see the date classes developed in lecture and posted online. a. [Done] How can we use either int or String to manipulate month values? [ overloading methods, utility conversion methods ] b. [Done] How can we create an object and initialize it all in one step? [ Constructors ] c. [Done] How can we prevent setting invalid values for instance variables? [ make instance variables private and create get. . and set. . methods ] d. [Done] How can we get nicely formatted output when we display an object using System.out.println(…)? * implementing the toString() method ] e. [Done] How can we chain code in Constructors so we don't have to write the same code multiple times? [ chain constructors using
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: this as the first action in the constructor ] To do this use this( . . parameters here); which will chain to the matching Constructor in the class. Problem: f. * Here+ How can we make a copy of an object? [ copy constructor] Deep vs. Shallow copy of an object: Consider having an Employee class that itself has in instance of Date . Create a copy constructor for the Employee class. What happens to the Date? g. How can we do a deep comparison of objects? [ implement an equals(. .) method ] Problems and [ solutions ], not necessarily in the following order. Last Time & Today: 10-07 Class Notes CS 107 Friday, October 07, 2011 3:08 PM CS 107 Fall 2011 Page 1...
View Full Document

Ask a homework question - tutors are online