In Lab 6

October 9, 2007

Purpose:

The purpose of this lab is to re-inforce your object oriented programming skills, start using control structures, as well as get you used to using the Java API.

What to do:

You will need a Driver class that holds your main method. In the main method you will instantiate the second class you will need, the StringParser class. The StringParser constructor will initialize 4 Strings that you get from user input. You can use the Scanner class or JOptionPane to accept user input. After you initialize the Strings you will automatically return back to the Driver class. The driver class will call a method in the StringParser class to start the program. The method to start the program will go into a loop and print the menu below. The menu will consists of five choices:
  1. Press 1 to find the largest String.
  2. Press 2 to search for a a particular String.
  3. Press 3 to search for a particular substring anywhere in the string.
  4. Press 4 to exit.
You should use a iteration statement, print the menus and use a if/else statement to call the appropriate methods in the StringParser class to complete the tasks chosen in the menu.

Hint

Compile often. First get the two classes up and running with the proper code in the constructor of the StringParser class. Then get the static menu method working, then the switch statement calling the correct methods, enclose that in the loop so it will work until 5 is input. Then start writing each method, method by method. Use the String methods in the Java API to solve the problems stated in the menu.

Turn in

Get as much as you can done before you leave the lab. Make sure your TA or Consultant checks off what you have completed before you leave the lab. If you don't finish before the end of the lab, make sure you have it turned in by Thursday evening. Debzani will be going over this in lecture on Friday and your lab must be turned in before she goes over it.