Dragon.java


Below is the syntax highlighted version of Dragon.java from §1.5 Input and Output.


/******************************************************************************
 *  Compilation:  javac Dragon.java
 *  Execution:    echo F F | java Dragon | java Dragon | java Dragon
 *  Dependencies: StdOut.java StdIn.java
 *
 *  Prints the instructions for drawing a dragon curve of orders N
 *  using piping.
 *
 *  % echo F F | java Dragon
 *  FLF FRF
 *
 *  % echo F F | java Dragon | java Dragon
 *  FLFLFRF FLFRFRF
 *
 *  % echo F F | java Dragon | java Dragon | java Dragon
 *  FLFLFRFLFLFRFRF FLFLFRFRFLFRFRF
 *
 ******************************************************************************/

public class Dragon {
    public static void main(String[] args) {
        String dragon = StdIn.readString();
        String nogard = StdIn.readString();
        StdOut.print(dragon + "L" + nogard);
        StdOut.print(" ");
        StdOut.print(dragon + "R" + nogard);
        StdOut.println();
    }
}


Copyright © 2000–2022, Robert Sedgewick and Kevin Wayne.
Last updated: Thu Aug 11 10:14:17 EDT 2022.