/****************************************************************************** * Compilation: javac RandomText.java * Execution: java RandomText text n * Dependencies: StdDraw.java * * Plots the specified text n times at random locations, in random colors. * * % java RandomText Hello 10 * * % java RandomText World 15 * * % java RandomText Java 20 * * ******************************************************************************/ import java.awt.Color; import java.awt.Font; public class RandomText { public static void main(String[] args) { String text = args[0]; int n = Integer.parseInt(args[1]); StdDraw.clear(Color.BLACK); Font font = new Font("Arial", Font.BOLD, 60); StdDraw.setFont(font); for (int i = 0; i < n; i++) { StdDraw.setPenColor(Color.getHSBColor((float) Math.random(), 1.0f, 1.0f)); double x = Math.random(); double y = Math.random(); StdDraw.text(x, y, text); } } }