Computer Science Fundamentals (CS153 2004S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
[Search]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[Experiments in Java]
[Java API]
[Scheme Reference]
[Scheme Report]
[CS153 2003S]
[CS151 2003F]
[CS152 2000F]
[SamR]
Back to Discussion of Exam 2. On to Conditionals.
Held: Friday, 12 March 2004
Summary: Today we consider how to make classes and objects that encapsulate values and provide capabilities.
Related Pages:
Overview:
Rational class.
import ClassWhoseNameYouDontWantToTypeInFull;
/**
* A helpful introductory comment that describes the class.
*/
public class ClassName
{
// Field declarations
// Constructors
// Methods
} // class ClassName
protected
protected String name;
anywherein the class; variables are available only in the method they are declared in.
this.
public). + The type of value the method returns. You can use
void when a method doesn't return anything.
public String getName()
{
return this.name;
} // getName()
public void setName(String newName)
{
this.name = newName;
} // setName(String)
Point and Fraction classes are template
classes.
main method. You can
think of the main method as a combination of the script
and directory of a play. This method creates the objects that form
the initial actorsof the play that is your program. It then tells them what to do.
Back to Discussion of Exam 2. On to Conditionals.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
[Search]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[Experiments in Java]
[Java API]
[Scheme Reference]
[Scheme Report]
[CS153 2003S]
[CS151 2003F]
[CS152 2000F]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri May 7 09:43:21 2004.
The source to the document was last modified on Tue Jan 13 10:26:11 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2004S/Outlines/outline.31.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby