This is Monday, June 30. July starts tomorrow. 

import java.util.Scanner; 
import javax.swing.JFrame;

class One {
  public static void main(String[] args) {
    Scanner timmy = new Scanner(System.in); // getting ready to read from the keyboard 
    JFrame laura = new JFrame("Blah blah blah."); // does this create an object or not? Where is it? 
    System.out.println( timmy ); 
    System.out.println( laura ); 
    laura.setSize(200, 500); 
    laura.setVisible(true); 
  }
}

This runs and prints:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run One
java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q?\E]
javax.swing.JFrame[frame0,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=Blah blah blah.,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


I also creates and shows a JFrame like in Tetris. 

Next we discussed how we can invoke methods from other classes:

class LabOne {
  public static void main(String[] args) {
    Spider.main( null ); // null is the missing array of Strings  
    Owl.main( null ); // null is the missing array of Strings
  }
}

This example provided by Amber. 

Next we define our first method:

import java.util.Scanner; 

class LabFive {
  public static void main(String[] args) {
    Scanner a = new Scanner(System.in);     
    System.out.print("Size: "); // cursor stays on line for user input 
    // user types something, the scanner should read it 
    int size = a.nextInt(); 

    LabFive.rainbow(size); 
  }
  
  public static void rainbow(int size) { // size is defined from here ...
    for (int count = 0; count < size; count = count + 1) {
      System.out.print("* ");  
    }
    System.out.println(); 
  } // ... to here 
}

This is what this prints: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run LabFive
Size:  [DrJava Input Box]
* * * * * * * * * * * * 


Now I make a change:

import java.util.Scanner; 

class LabFive {
  public static void main(String[] args) {
    Scanner a = new Scanner(System.in);     
    System.out.print("Size: "); // cursor stays on line for user input 
    // user types something, the scanner should read it 
    int size = a.nextInt(); 

    for (int count=0; count < size; count = count + 1) { 
      LabFive.rainbow(size); 
    }
  }
  
  public static void rainbow(int size) { // size is defined from here ...
    for (int count = 0; count < size; count = count + 1) {
      System.out.print("* ");  
    }
    System.out.println(); 
  } // ... to here 
}

This now works as follows:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run LabFive
Size:  [DrJava Input Box]
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
* * * * * * * * * * * * 
>

Next we worked on these problems:

True or false?

1. A method has exactly one return statement.

False 

2. A method has at least one return statement.

False

3. A method has at most one return value.

False 

class Three {
  public static void main(String[] args) {
    System.out.println( leap(1976) ); 
    System.out.println( leap(1540) ); 
    System.out.println( leap(1541) ); 
  }
  public static String leap(int year) {
    if (year < 1582) {
      if (year % 4 == 0) { 
        return year + " is a leap year"; 
      } else {
        return year + " is not a leap year"; 
      }
    } else {
      return "Leave me alone. I don't do " + year; 
    }
  }
}

4. A method with return value void never has a return statement.

False because you can have a blank return statement.

5. When executing a return statement, the method exits immediately.

True.

class Three {
  public static void main(String[] args) {
    System.out.println( leap(1976) ); 
    System.out.println( leap(1540) ); 
    System.out.println( leap(1541) ); 
  }
  public static String leap(int year) {
    if (year < 1582) {
      if (year % 4 == 0) { 
        return year + " is a leap year"; 
      } else {
        return year + " is not a leap year"; 
      }
    } else {
      return "Leave me alone. I don't do " + year; 
      System.out.println("How do you like this?");
    }
  }
}

6. A method without parameter variables always returns the same value.

True

Math.random()

False?

Ha ha.

--


Team One:   Zichao Wang    , Yinan Zhang   , Mary Anne Smart , Kexin Zhang
Team Two:   Justin Budka   , Max Zhou      , Neelan Scheumann, Kyle Nealy
Team Three: Lindsay Koons  , Staci Thompson, Erik Mikac      , Justin Smock 
Team Four:  Jason Sprinkle , George Witwer , Alexander Sereno, Kyle Cunningham
Team Five:  Austin Schiffer, Jordan Marks  , Adam Kruchten   , Adam Johnson
Team Six:   Ruifeng Li     , Yi Lu         , Hang Zhou       , Yunsheng Yao    , Maxine Poorman