Howdy. 

Wednesday exam. 

http://silo.cs.indiana.edu:8346/cgi-bin/fall2018/schedule

https://www.cs.indiana.edu/classes/c212-dgerman/fall2018/ports.html

09/30 

Homework 03

Right now we know what unit testing is but we can't automate it

JUnit allows you to do that (we start in Chapter 08)

Unitl then it's all in the eye of the beholder 

You can appeal (to your UI/AI/TA) and also make up (with me). 

GitHub does not close. 

--

Homework 05 is about Chapter 03.

1. Intro 

2. Use Objects

3. Defining Classes 

4. Fundamental Data Types

5. Decisions

6. Loops

--

Fraction a, b; 

a = new Fraction(1, 2); 

b = new Fraction(2, 3); 

Fraction c = a.add(b); // new Fraction( 1 * 3 + 2 * 2 , 3 * 2 ); 

// Car Student 

(a) need class
(b) instance variables (data) 
(c) constructor (initialization procedure)
(d) instance methods (behavior) 
(e) set up some battery of tests

public class Fraction {
  int num, den; // although instance variables should always be private
  public Fraction(int n, int d) {
    num = n;
    this.den = d; 
  } 
  public Fraction add(Fraction other) {
    // one of the fractions is other, the other one is this (implicit param)
    int rNum = other.num * den + other.den * this.num; 
    int rDen = other.den * this.den; 
    // we forgot this 
  }

  public String toString() {
    return this.num + "/" + this.den; 
  }

  public static void main(String[] args) {
    Fraction a, b; 
    a = new Fraction(1, 2); 
    System.out.println( a.toString() ); 
    b = new Fraction(2, 3); 
    System.out.println( b.toString() ); 
    Fraction c = a.add(b); // new Fraction( 1 * 3 + 2 * 2 , 3 * 2 ); 
    System.out.println( c.toString() ); 
  }   
}

--

public class Fraction {
  int num, den; // although instance variables should always be private
  public Fraction(int n, int d) {
    num = n;
    this.den = d; 
  } 
  public Fraction add(Fraction other) {
    // one of the fractions is other, the other one is this (implicit param)
    int rNum = other.num * den + other.den * this.num; 
    int rDen = other.den * this.den; 
       
    return new Fraction(rNum, rDen); 
  }

  public String toString() {
    return this.num + "/" + this.den; 
  }

  public static void main(String[] args) {
    Fraction a, b; 
    a = new Fraction(1, 2); 
    System.out.println( a.toString() ); 
    b = new Fraction(1, 2); 
    System.out.println( b.toString() ); 
    Fraction c = a.add(b); // new Fraction( 1 * 2 + 1 * 2 , 2 * 2 ); 
    System.out.println( c.toString() ); 
    System.out.println( a.toString() + " + " + b.toString() + " = " + c.toString() );
  }   
}

https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html

https://docs.oracle.com/javase/7/docs/api/overview-tree.html

https://docs.oracle.com/javase/7/docs/api/overview-summary.html

https://docs.oracle.com/javase/7/docs/api/

http://www.horstmann.com/bigjava.html

--