// purpose: use the im import java.util.*; public class ConsoleIM { public static void main( String[] args ) { Scanner stdin = new Scanner( System.in ); System.out.print( "Who are you: " ); String user = stdin.nextLine(); System.out.println(); IM im = new IM( user ); System.out.println( "IM: " + im ); System.out.println(); System.out.print( "Friend to instant message: " ); String friend = stdin.nextLine(); System.out.println(); for ( int i = 0; i < 10; ++i ) { String reply = im.getMessage( friend ); System.out.println( "----- " + friend + " says:\n" + reply ); System.out.println(); System.out.print( "Response to " + friend + ": " ); String text = stdin.nextLine(); im.sendMessage( friend, text ); System.out.println(); System.out.println( "Pausing for 6 seconds" ); pause( 6 ); System.out.println(); } } public static void pause( double n ) { try { Thread.sleep( (int) ( n * 1000 ) ); } catch ( InterruptedException e ) { } } }