

public class Howdy {

    public int width,height;
    public String[] buf;

    public Howdy(int w,int h){
        width = w;
        height = h;
        buf = new String[width * height];
        clear();
    }

    public void plot(int x,int y,String s){
        int idx = y * width + x;
        if(idx >= buf.length){
            System.err.println("Out of bounds: "+x+","+y+"");
        }else{
            buf[idx] = s;
        }
    }

    public void circle(int x,int y,int r,String s){
        for(double theta=0;theta<2*Math.PI;theta+=Math.PI/30){
            int X = (int)(Math.cos(theta) * r) + x;
            int Y = (int)(Math.sin(theta) * r) + y;
            plot(X,Y,s);
        }
    }

    public void line(int x1,int y1,int x2,int y2,String s){
        // line from point x1,y1 to x2,y2
    }

    public void clear(){
        for(int i=0;i<buf.length;i++){
            buf[i] = " ";
        }
    }

    public void flush(){
        for(int y = 0; y < height ; y++){
            for(int x = 0; x < width ; x++){
                System.out.print(buf[ y * width + x ].charAt(0));
            }
            System.out.println("");
        }
    }

    public static void main(String[] args) throws Exception {
        Howdy h = new Howdy(78,30);
        for(int i=0;i<10;i++){
            h.circle(h.width/2,h.height/2,i,"#");
            h.flush();
            h.clear();
            Thread.currentThread().sleep(500);
        }
    }
}


