Hows my code v.week #2

Discussion in 'OT Technology' started by Spur, Oct 11, 2004.

  1. Spur

    Spur Boomer

    Joined:
    Nov 14, 2001
    Messages:
    3,685
    Likes Received:
    5
    Location:
    AZ
    I had to accomplish this here




    heres my code:
    Code:
    public class DrawRocket {
    	public static final int HEIGHT = 2;  // Rocket will change size by just changing HEIGHT constant.
    	public static void main (String[] args) {
    		drawCone();
    		drawLine();
    		drawUpBox();
    		drawDownBox();
    		drawLine();
    		drawDownBox();
    		drawUpBox();
    		drawLine();
    		drawCone();
    	}
    
    	//This creates the cone part which is the top and bottom portions of the rocket.
    	public static void drawCone () {
    		for (int row = 2 * HEIGHT; row >= 0; row--) {
    			for (int col = 1; col <= row + 1; col++)
    				System.out.print (" ");
    			for (int col = HEIGHT; col >= row - HEIGHT; col--)
    				System.out.print ("/");
    			System.out.print ("**");
    			for (int col = HEIGHT; col >= row - HEIGHT; col--)
    				System.out.print ("\\");
    			for (int col = 1; col <= 4 - row; col++)
    				System.out.print (" ");
    			System.out.println ();
    		}
    	}
    
    	//This creates the divider lines/decorative trim on the rocket ship.
    	public static void drawLine () {
    		System.out.print ("+");
    		for (int col = 1; col <= 2 * HEIGHT + 2; col++) {
    			System.out.print ("=");
    			System.out.print ("*");
    		}
    		System.out.print ("+");
    		System.out.println();
    	}
    
    	//This creates the up pointing triangle box.
    	public static void drawUpBox () {
    		for (int row = HEIGHT; row >=0; row--) {
    			System.out.print ("|");
    			for (int col = 1; col <= row; col++)
    				System.out.print (".");
    			for (int col = HEIGHT; col >= row; col--)
    				System.out.print ("/\\");
    			for (int col = 1; col <= 2 * row; col++)
    				System.out.print (".");
    			for (int col = HEIGHT; col >= row; col--)
    				System.out.print ("/\\");
    			for (int col = 1; col <= row; col++)
    				System.out.print (".");
    			System.out.print ("|");
    			System.out.println ();
    		}
    	}
    
    	//This creates the down pointing triangle box.
    	public static void drawDownBox () {
    		for (int row = HEIGHT; row >= 0; row--) {
    			System.out.print ("|");
    			for (int col = HEIGHT; col >= row + 1; col--)
    				System.out.print (".");
    			for (int col = 1; col <= row + 1; col++)
    				System.out.print ("\\/");
    			for (int col = HEIGHT; col >= row + 1; col--)
    				System.out.print ("..");
    			for (int col = 1; col <= row + 1; col++)
    				System.out.print ("\\/");
    			for (int col = HEIGHT; col >= row + 1; col--)
    				System.out.print (".");
    			System.out.print ("|");
    			System.out.println ();
    		}
    	}
    }
    

    I don't have to turn it in til 9pm PST. I really appreciate your comments tho.
     

Share This Page