A class is a container. 

It contains members (static or non-static). 

Non-static members form a blueprint, like a stamp. 

Blueprint is like a vision, you can instantiate it to create objects. 

class Student {
  public static void main(String[] args) {
     Student a = new Student(); 
     System.out.println( a ); 
     Student b; 
     b = new Student(); 
     System.out.println( b ); 
  }
}

Later on the code became: 

public class Student {
  Student() {
    
  }
  private String name;
  public void talk() {
    System.out.println( "Hi, my name is: " + name);  
  }
  public String getName() {
    return name; 
  }
  public void setName(String newName) {
    name = newName; 
  }
  public Student(String initialName) {
     name = initialName; 
  }
}

We separated the main method from this class: 

class Example {
  public static void main(String[] ags) {
    Student a = new Student("Leslie");
    System.out.println( a.getName() );
    a.talk(); 
  }
}

If we compile and run Example.java we get something like this: 

-bash-4.1$ cat Student.java
public class Student {
  Student() {

  }
  private String name;
  public void talk() {
    System.out.println( "Hi, my name is: " + name);
  }
  public String getName() {
    return name;
  }
  public void setName(String newName) {
    name = newName;
  }
  public Student(String initialName) {
     name = initialName;
  }
}
-bash-4.1$ cat Example.java
class Example {
  public static void main(String[] ags) {
    Student a = new Student("Leslie");
    System.out.println( a.getName() );
    a.talk();
  }
}
-bash-4.1$ javac Example.java
-bash-4.1$ java Example
Leslie
Hi, my name is: Leslie
-bash-4.1$

Next we discussed BlueJ and here's the download link:

http://www.bluej.org/download/download.html

Here's what we did with BlueJ:

http://www.cs.indiana.edu/classes/c212/sum2013/06202013.png

--

In lab today: 

(a) solve the eight problems and explain your answers

(b) complete the code for Car

Things to keep in mind: 

(a) instance members: one per object

static (class) members: one per class

access members via: object reference if instance
                    class name if static 

this is a keyword that objects use to refer to themselves

(b) here's the Car problem statement: 

  Design a class of objects called Car.

  A Car has fuel inside.

  You can add more fuel to it.

  You can drive a Car.

  When you drive it it burns one gallon of gas every so many miles.

  Create a Car with an initial efficiency (miles per gallon). 

  A Car would report() its state (the amount of fuel in its tank)

Here's a test program:

  class Car {
    // this part is your responsibility
  }

  class Exam {
    public static void main(String[] args) {
      Car a = new Car(50);
      a.report();
      a.addFuel(3.2);
      a.report();
      a.drive(27);
      a.report();
    }
  }

It should produce when compiled and run:
  
  New Car being created (efficiency 54 miles/gallon).

  Car with 0 gallons of fuel.

  3.2 gallons added.

  Car with 3.2 gallons of fuel.

  Car being driven 27 miles.

  Car with 2.7 gallons of fuel.

Or something to that effect.

Interactive template for this problem: 

  http://www.cs.indiana.edu/classes/a290-java/fall2012/templates/seven.htm

--