//sounds.java import java.io.*; import java.util.*; public class Sounds { Console c; Vector animals, sounds; PrintWriter d; BufferedReader b; public Sounds() { c = new Console(); animals = new Vector(); sounds = new Vector(); try { b = new BufferedReader( new FileReader( "sounds.txt" ) ); } catch( Exception e ){} if ( b != null ) loadData(); } public static void main( String[] args ) { new Sounds().begin(); } private void begin() { c.echo("Collecting sounds: " ); String animal = "", sound = ""; c.echo( "Enter animal name and sound when prompted: " ); while ( true ) { c.echo( "Name: " ); animal = c.read(); if ( animal.equals( "" ) ) break; c.echo( "Sound: " ); sound = c.read(); if ( sound.equals( "" ) ) break; c.echo( "You entered " + animal + " " + sound ); animals.add( animal ); sounds.add( sound ); }//end while c.echo( "You entered the folloiwng: " ); for ( int i = 0; i < animals.size(); i++ ) { c.echo( animals.get(i) + "---> " + sounds.get(i) ); } } private void loadData() { while (true) { try { if ( ( line = b.readLine() ) == null ) break; } catch ( Exception e) { break; } } } }