Howdy. 

You got copies fo Exam 01 in Summer 2018. You can keep it. 

On the paper that I gave you: name/date, top 5 challenging questions on the exam.

I'd like you to write them in descending order of difficulty.

I also want the top 5 easy questions, as far as you can tell now. 

So far you read: chapter 1, 2, 3. 

Reading assignment for Wed 09/05: Chapter 4. 

Reading assignment for Mon 09/10: Chapter 5. 

Reading assignment for Wed 09/12: Chapter 6. 

Reading assignment for Mon 09/17: Chapter 7. 

Early Evaluation Exam: Wed 09/19.

Soon we will post UIs/TAs/AIs office hours. 

I have posted Homework 01, Lab 02, Homework 02 on the website.

Canvas will accept these until we set up GitHub accounts. 

import java.util.Scanner;

public class Homework01 {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in); 
    System.out.print("Enter first time: "); 
    String a = in.nextLine(); 
    System.out.println( a ); 
    Integer hours = Integer.parseInt( a.substring(0, 2) );  
    Integer minutes = Integer.parseInt( a.substring(3) );  
    int t1 = hours * 60 + minutes;
    System.out.println( t1 ); // "19:05" -> 1145, "10:23" -> 623
  }
}

Chapter 1: Compile and Run Programs. Java Programs = Classes.

Chapter 2: Using Objects (BigDecimal, Scanner, JFrame, Graphics, etc.)

Chapter 3: Design and Create Objects 

public class Horse {
  public void talk() {
    System.out.println(this + " says: Howdy.");  
  }
  public static void main(String[] args) {
    Horse a, b; 
    a = new Horse(); 
    System.out.println( a + " has been created.");
    a.talk(); 
    b = new Horse(); 
    System.out.println( b + " has been created.");
    b.talk(); 
    a.talk(); 
  }
}

The class above minimally models a horse.

There is no constructor that you can see. 

When there is no explicit constructor for a class provided 
by the programmer Java gives you a no-args default constructor. 

talk() is an instance method. 

public class Horse {
  public void talk() { // method, function (instance) 
    System.out.println(this + " says: Howdy.");  
  }
  public String neigh() {
    return " muffled sound "; 
  }
  public static void main(String[] args) {
    Horse a, b; 
    a = new Horse(); 
    System.out.println( "(main) " + a + " has been created.");
    a.talk(); 
    System.out.println( "(main) " + a + " sent us a " + a.neigh() ); 
    b = new Horse(); 
    System.out.println( "(main) " + b + " has been created.");
    b.talk(); 
    a.talk(); 
  }
}

There are four kinds of variables: 

  (a) static variables (in a class, outside methods, marked static) 

  (b) instance variables (in a class, outside methods, not static)

  (c) local variables (defined inside a method) 

  (d) parameters (listed in the signature of a method)

We'll say more about these later. 

https://media.kohlsimg.com/is/image/kohls/1642490?wid=500&hei=500&op_sharpen=1

Why do they put bells on cows? 

public class Unicorn extends Horse {
  
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Unicorn a = new Unicorn()
> a.talk()
Unicorn@3fbf0ed8 says: Howdy.
> a.neigh()
" muffled sound "


public class Unicorn extends Horse {
  public void fleigh() {
    System.out.println( this + ": Aleigh says I can do this." );  
  }
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Unicorn a = new Unicorn()
> a.talk()
Unicorn@28308043 says: Howdy.
> a.neigh()
" muffled sound "
> a.fleigh()
Unicorn@28308043: Aleigh says I can do this.


Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Unicorn a = new Unicorn()
> a.talk()
Unicorn@25627e95: as a Horse I'd say Unicorn@25627e95 says: Howdy.
Unicorn@25627e95: Bonjour.
> Horse b = new Unicorn()
> b.talk()
Unicorn@364e7b58: as a Horse I'd say Unicorn@364e7b58 says: Howdy.
Unicorn@364e7b58: Bonjour.


public class Unicorn extends Horse {
  public void fleigh() {
    System.out.println( this + ": Aleigh says I can do this." );  
  }
  public void talk() {
    // System.out.print( this + ": as a Horse I'd say ");  
    // super.talk(); 
    System.out.println( this + ": Bonjour." ); 
  }
}