Here are the grading assignments for the first two weeks

Yudou (Phoebe) He: Badger, Bogdanoff, Crutchfield, Feltner, 
Hebda, Langston, Mitts, Pedersen, Richards, Schumacher, Welsh 

Seth (Xiaohui) Wang: Barnes, Branson, Curtis, Fu, Holmes, Man, 
Niu, Qian, Robinson, Shepherd

Adrian German (dgerman): Bobe, Corradin, Dai, Garcia, Jackson, 
Mantz III, Ong, Reddigari, Root, Song

We are going to rotate after two weeks, then again in two more. 

Assignments will be due (let's say) at 5pm. Grace period of until
midnight will mark submissions as late (no penalty points). You can
appeal your grade to your grader and/or retake the assignment as a
test in person in LH204 (or similar) with dgerman for a better grade. 

My question to you is this: what's the best policy in your opinion
for assignments that have not been turned in on time (even late)? 

Download DrJava and get started. 

Java programs are made of classes. 

Each class contains a blueprint. 

Blueprints are used to create (instantiate) objects. 

Classes are therefore models (for objects). 

Classes are also containers. 

Classes contain members (variables and procedures). 

Procedures are called methods. 

Members can be: static and non-static. 

Besides members a class may also contain constructors. 

A constructor is not a member. It's like a procedure. 

Unlike a procedure though a constructor: 

(a) does not have a return type (void is a return type)

(b) has the name of the class (a method can have any name it wants)

There are four kinds of variables in Java:

(a) local variables (of the kind you see in main)

(b) parameters (arguments) 

Local variables need to be initialized by the programmer. 

Parameters get their initial value from the function call. 

(c) static variables (defined in class, outside methods)

(d) instance variables (non-static, in class, outside method)

In Java there are two kinds of types: 

(a) primitive types 
       whole numbers: int, long, byte, short
       numbers with decimals: double, float 
       characters: char
       booleans; boolean  

(b) classes (non-primitive, user-defined, reference types)

--

public class Point {
  int x, y; // instance variables
  Point(int x, int b) { // constructor
    // x and b are parameters
    this.x = x; 
    y = b;     
  }
  Point() {
    this(0, 0); 
  }
  double distanceTo(Point other) {
    int dx, dy; 
    dx = this.x - other.x; 
    dy = this.y - other.y; 
    return Math.sqrt( dx * dx + dy * dy );
  }
  public static void main(String[] args) {
    Point a, b; // local variables 
    a = new Point(3, 0); 
    b = new Point(0, 4);
    double d = a.distanceTo(b); 
    System.out.println( d ); // it should print 5.0 
    d = Point.origin.distanceTo(new Point(1, 1)); 
    System.out.println( d ); // it should print 1.4142...

  }
  static Point origin = new Point(); 
}

Once we compile and run we get:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java Point
5.0
1.4142135623730951


Reading assignment for today: chapter 2 (fundamental data types). 

Reading assignment for tomorrow: chapter 3 (decisions). 

I am going to write a program that asks the user for a name and
then using the name ask the user about her/his age. Then the program
will calculate the age next year and report it. 

import java.util.Scanner; 

public class LectureTwo {
  public static void main(String args[]) {
    Scanner speckles; 
    speckles = new Scanner(System.in); // create a Scanner that reads from the keyboard
    System.out.println("What's your name? "); 
    String name = speckles.nextLine(); 
    System.out.println("How old are you, " + name + "? "); 
    String age = speckles.nextLine(); 
    System.out.println( name + " you will be " + ( age + 1 ) + " next year.");     
  } 
}

This is good but there are some shortcomings. We fix them and we have: 

import java.util.Scanner;

public class LectureTwo {
  public static void main(String args[]) {
    Scanner speckles;
    speckles = new Scanner(System.in); // create a Scanner that reads from the keyboard
    System.out.print("What's your name? ");
    String name = speckles.nextLine();
    System.out.print("How old are you, " + name + "? ");
    String age = speckles.nextLine();
    int n = Integer.parseInt( age ); 
    System.out.println( name + " you will be " + ( n + 1 ) + " next year.");
  }
}

This runs as follows: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java LectureTwo
What's your name?  [DrJava Input Box]
How old are you, Tom?  [DrJava Input Box]
Tom you will be 6 next year.


Clearly we entered Tom and 6 in the two boxes. 

See you in lab. 

--