Overview

Rough Outline of Organization

Classes

Classes: Human Example

   public class Human {
         // Properties of humans
         private String   name;
         private Date     birthdate;
         private int      beardLength;

         // Constructor (more on this in a minute)
         public Human(String n, Date d, int blen) {
               statements;
               ....
         }

         // Methods of humans
         public void run(int distance, int direction, int speed) {
               statements;
               ....
         }

         public void sit() {
               statements;
               ....
         }

         public void sleep(int duration) {
               statements;
               ....
         }

         // Other Methods of humans, used to get/set the properties
         public String getName() {
               return name;
         }
         public Date getBirthDate() {
               return birthdate;
         }
         public int getBeardLength() {
               return beardLength;
         }
         public void setName(String n) {
               name = n;
         }
         public void setBirthDate(Date d) {
               birthdate = d;
         }
         public void setBeardLength(int blen) {
               beardLength = blen;
         }
   }

Classes: Notes about Human Example

Creating Classes of Objects

Constructors & Creating Objects

   public class Human {
         // Properties of humans
         private String   name;
         private Date     birthdate;
         private int      beardLength;

         // Constructor (more on this in a minute)
         public Human(String n, Date d, int blen) {
               setName(n);
               setBirtDate(d);
               setBeardLength(blen);
         }

         ...

Calling Methods

Comments

   /*    File: HomerWantDonut.java
    *  Author: Ryan Flannery <ryan.flannery@gmail.com>
    *    Date: 15 June 2010
    * Purpose: This program attempts to simulate the Homericaus Americanus
    *          (colloquially “Homer”) in his futile, often humerous
    *          attempts at obtaining a pink glazed donut with sprinkles.
    *          We compare our results with observations from over 200 episodes and
    *          draw a number of what we believe to be key conclusions about
    *          the socioeconomic and political motivations behind this epic struggle,
    *          akin to Ahab's struggle against Moby.
    *
    * Submitted: Journal of Nature, July 2010.
    *    Status: REJECTED
    */

Access Specifiers

Access Specifiers for Classes

Access Specifiers for Methods and Properties

Access Specifiers: Example

Conclusion