Lecture 6: Creating & Using Java Classes

This lecture explores how the concepts discussed in Lecture 5 are realised in Java. It starts from a UML diagram describing a class to represent a time of day, and shows how the different elements of this class can be built up piece by piece - starting with private fields, then moving on to implement constructors that create instances of the class, then public getter methods for the fields, then setter methods. The lecture considers the issue of whether setters should be private, making Time objects immutable, or whether they should be public, allowing changes of object state. It finishes with a look at other features of the class, such as the toString method.