CSC152 2005F, Class 13: Object Basics, Continued Admin: * I hope to return HW1 on Monday * HW2: Do the Class Basics lab in Espresso. (Due Wed.) * Agh! It's Friday, the 13th (class) * Eryn has candy. Feel free to take some unless your parents told you to never take candy from strangers (since Eryn is stranger than most people) Overview: * Review * Methods * Detour: Three kinds of classes * Standard methods * Class methods and fields Review: * Classes provide templates for creating objects * Template classes have five (or so) parts * Fields - Information about the object (or that the object uses) * Constructors - Let you construct new objects * Methods - Instructions objects can use to do stuff * Class Fields - Associated with the class as a whole, rather than infidivudal methods * Class Methods * Class construction usually starts with *design* * Then express that design in Java * Review continues with example (see link) * Note: The /** ... */-style comments make it easier to automatically generate documentation: (alpha) Add the following alias to your .bashrc alias jdoc='/opt/jdk1.5.0/bin/javadoc -version -author -tag pre:m:"Preconditions" -tag post:m:"Postconditions"' (a) Create a directory for your documentation, such as /home/username/public_html/CSC152/Documentation (b) cd to that directory (c) type "jdoc package1.name package2.name ..." (d) Check permissions! (e) Open the directory in a Web browser (e.g., http://www.cs.grinnell.edu/~username/CSC152/Documentation/) /Methods/ * Form PROTECTION RETURN-TYPE NAME(PARAMETERS) { INSTRUCITIONS } // NAME(PARAMETER-TYPES) * Legal "instructions" * Variable declarations of the form TYPE NAME; * Assignment statements of the form NAME = EXP; * Method calls of the form OBJECT.METHOD(PARAMS) * Control statements, which you learn about next week * Return statements, of the form return EXP;