
/* Simulation of console-I/O program RowsOfChars,
   using ConsoleApplet as a basis.  See the file
   ConsoleApplet.java for more information.
   
   David Eck
   eck@hws.edu
   
*/

public class RowsOfCharsConsole extends ConsoleApplet {

   protected String getTitle() {
      return "Sample program \"RowsOfChars\"";
   }

   protected void program() {
       String inputLine;  // Line of text input by user.
       console.put("Enter a line of text: ");
       inputLine = console.getln();
       console.putln();
       printRowsFromString( inputLine );
   }

   void printRowsFromString( String str ) {
          // For each character in str, write a line of output
          // containing 25 copies of that character.
      int i;  // Loop-control variable for counting off the chars.
      for ( i = 0; i < str.length(); i++ ) {
          printRow( str.charAt(i), 25 );
       }
   }
  

   void printRow( char ch, int N ) {
          // Write one line of output containing N copies of the
          // character ch.  If N &lt;= 0, an empty line is output.
      int i;  // Loop-control variable for counting off the copies.
      for ( i = 1; i <= N; i++ ) {
          console.put( ch );
       }
       console.putln();
   }
               
 
}
