1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| package lianxi;
import java.util.*; import java.io.*;
public class lianxix { private String name; private Formatter f; public lianxix(String name, Formatter f){ this.name = name; this.f = f; } public void move(int x, int y) { f.format("%s The lianxix is at (%d, %d)\n", name, x, y); } public static void main(String[] args) { PrintStream outAlias = System.out; lianxix tommy = new lianxix("Tommy", new Formatter(System.out)); lianxix terry = new lianxix("Terry", new Formatter(outAlias)); tommy.move(0, 0); terry.move(1, 2); } }
|