Spring Semester 2004

Reading Assignment One


We will summarize Wu's book in these reading assignments.

Chapter 0 is extremely general, we'll read it later.

Chapter 1 is useful, but still general. We'll come back to it.

We'll start with Chapter 2. We'll also take a look at Appendix A.

Here are the eight programs developed by Wu's Chapter 2.

import javax.swing.*;

class One {
  public static void main(String[] args) {
    JFrame myWindow;
    myWindow = new JFrame(); 
    myWindow.setSize(300, 200);
    myWindow.setTitle("How are you, people?"); 
    myWindow.setVisible(true); 
  }
}
At this point we need to show you how to use javabook.

Here it is as a Java archive.

import javabook.*;

public class Two {
  public static void main(String[] args) {
    SketchPad doodleBoard;
    doodleBoard = new SketchPad(); 
    doodleBoard.setVisible(true); 
  }
}
import javabook.*; 

public class Three {
  public static void main(String[] args) {
    MiniBrowser browser; 
    browser = new MiniBrowser(); 
    browser.setVisible(true); 
  }
}
import javax.swing.*;

public class Four {
  public static void main(String[] args) {
    JFrame jFrame;
    jFrame = new JFrame(); 
    jFrame.setSize(400, 300); 
    jFrame.setVisible(true); 
    JOptionPane.showMessageDialog(jFrame, "How are you?"); 
    JOptionPane.showMessageDialog(null, "Good Bye"); 
  }
}
import javax.swing.*;

public class Five {
  public static void main(String[] args) {
    String fullName, firstName, lastName, space; 
    fullName = new String("Larry Bird"); 
    space = new String(" "); 
    firstName = fullName.substring(0, fullName.indexOf(space));
    lastName = fullName.substring(fullName.indexOf(space) + 1, fullName.length());  
    JOptionPane.showMessageDialog(null, "Full Name: " + fullName); 
    JOptionPane.showMessageDialog(null, "First: " + firstName); 
    JOptionPane.showMessageDialog(null, "Last: " + lastName); 
    JOptionPane.showMessageDialog(null, "Your last name has " + lastName.length() + 
                                                                    " characters."); 
  }
}
import javax.swing.*; 
import java.util.*;
import java.text.*; 

public class Six {
  public static void main(String[] args) {
    Date today;

    SimpleDateFormat simpleDF1, simpleDF2; 
    today = new Date(); 
    
    simpleDF1 = new SimpleDateFormat(); 
    simpleDF2 = new SimpleDateFormat("EEEE MMMM dd, yyyy"); 
    
    JOptionPane.showMessageDialog(null, "Today is: " + simpleDF1.format(today)); 
    JOptionPane.showMessageDialog(null, "Today is: " + simpleDF2.format(today)); 
    
  }
}
import javax.swing.*; 

public class Seven {
  public static void main(String[] args) {
    String name;
    name = JOptionPane.showInputDialog(null, "What is your name?"); 
    JOptionPane.showMessageDialog(null, "Nice to meet you, " + name + "."); 
  }
}
import javax.swing.*; 

public class Eight {
  public static void main(String[] args) {
    String name, first, middle, last, space, monogram; 
    space = " "; 
    
    name = JOptionPane.showInputDialog(null, "Enter your full name (first, middle, last):"); 
    first = name.substring(0, name.indexOf(space)); 
    
    name = name.substring(name.indexOf(space) + 1, name.length()); 
    middle = name.substring(0, name.indexOf(space)); 
    
    last = name.substring(name.indexOf(space) + 1, name.length()); 
    
    monogram = first.substring(0, 1) + middle.substring(0, 1) + last.substring(0, 1); 
    
    JOptionPane.showMessageDialog(null, "Your monogram is " + monogram); 
  }
}
Read about them in Chapter 2.

Also, think about problem 27, page 83.

It might just be our Homework Assignment One.

We need the galapagos package and a brief tutorial.

Now that you've managed to use the .jar files here's a simplification of Lab One.

Summary is still forthcoming, so please take a look at Chapter Two and Appendix A first.


Last updated: Jan 17, 2004, by Adrian German for A201