There's an exam in class tomorrow, continues in lab. 

Chapter 1: Compiling Java. 
Chapter 2: Using Objects. 
Chapter 3: Implementing Classes. 
Chapter 4: Methods 
Chapter 5: Conditionals 
Chapter 6: Loops

Homework 06 will ask you to solve P6.2 (p. 298), P6.9 (p. 300), R6.32 (p. 294). 

Welcome to DrJava.  Working directory is C:\Users\dgerman
> boolean b
> int n
> n
0
> String a
> a
null
> b
false


Nows let's discuss this question:

Welcome to DrJava.  Working directory is C:\Users\dgerman
> int i = 6
> i
6
> i++
6
> i
7


When i is 6 i++ returns 6 and i becomes 7 in the process. 

When i is 7 ++i returns 8 and i is 8 after the expression evaluates. 

Welcome to DrJava.  Working directory is C:\Users\dgerman
> int i = 6
> i
6
> i++
6
> i
7
> ++i + 2
10
> i
8
> i++ + ++i

i is 8 then it seems to me that I have to add two things (expressions) 

The first one is i++ and the second one is ++i. I will evaluate those in order. 

When I do (1 + 2) + (5 - 3) I have the situation and I calculate it as follows

  3 + (5 - 3) then 
  3 + 2 then
  5

So the order is always left to right when there are no parens, so in our case

-- evaluate i++ this is an expression that returns i then (in the background) i is incremented by 1

That means I get an 8 and at this stage (before the rest is evaluated) i is ... 9.

> i++ + ++i
  
  8 and i is 9 
  8   + 
        10 and i is now 10 
  18 and i is 10 at the end

Great.

Welcome to DrJava.  Working directory is C:\Users\dgerman
> int i = 3
> i = ++i + i++

      4 and i is 4
      4   + 
            4 and i becomes 5 
      4   + 4
      8
So i becomes 8 but it started as 3 and became 4, 5 before becoming 8 and staying 8. 


Ankney, Garrett
Berry-Simms, Khalea not here 
Clark, Daniel
Cooper, Keiland
Cotter, Ryan
Gan, Kang Jie
Hay, Stuart
He, Kefei
Hiraga, Misato
Hu, Tao
Jing, Elise
Kaefer, John
Kowala, Katherine
Liu, Li
Matlock, Noah
https://animalso.com/wp-content/uploads/2016/10/pomsky_8.jpg
Navarro, Nicholas
Nieves, Rafael
O'dell, Taylor
Parker, Patrick
Pena, Jillian
Qian, Jiang
Reba, Christopher not here
Ruiz, Daniel
Salazar, Luis not here
Shen, Bihan
Stamets, Justin
Wang, Iris
Wang, Yibo

Let's look at exercises 1-5 from the sample exam. 

The questions are about methods. 

public class Circle {
  Point center; // instance variable
  double radius; // instance variable 
  public Circle(Point center, double radius) { // formal params, like local 
    this.center = center; 
    this.radius = radius; 
  }
  public double area() {
    return Math.PI * Math.pow(this.radius, 2); 
  }
}

class Point {
  int x, y; 
  static Point origin = new Point(); 
  // how does this work? what if we remove the word "static"?
  Point(int x, int b) {
    this.x = x; 
    y = b; 
  }
  Point() {
    this(0, 0); 
  } 
  double distanceTo(Point other) {
    return Math.sqrt( Math.pow( this.x - other.x, 2 ) + Math.pow( this.y - other.y, 2 ) ); 
  }
  public static void main(String[] args) {
    Point a = new Point(3, 0); 
    Point b = new Point(0, 4); 
    System.out.println(a.distanceTo(b)); // should print 5.0 
    System.out.println((new Point(1, 1)).distanceTo(new Point())); 
                                         // should print 1.4142135623730951 
  }
}

The code runs as follows: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Circle comet
> comet
null
> comet = new Circle(Point.origin, 4)
Circle@d225b8f
> comet.area()
50.26548245743669


So now we need to talk about methods (instance or not). 

Other expressions we discussed after lab: 

int i = a; // some initial value

Evaluate: 

    ++i + i++ // this is (a + 1) + (a + 1) 

    i++ + ++i // this is a + ((a + 1) + 1) 

Evaluate: 

    i-- - --i 

    i-- + --i 

    --i - i-- 

Which of these last three expressions do not depend on a? 

--