Re-Size Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Codeseeker99
    New Member
    • Jan 2008
    • 5

    #1

    Re-Size Issue

    my code works for SIZE 4, but I was trying to get my code to Re-Size in SIZE 3, SIZE 7. If you can look at my "for (int" and let me know what I need to change to get it to work in all three sizes.

    Code:
    // Figure out math loops for new sizes
    public class SpaceTest {
    		public static final int SIZE = 4;
    		public static void main(String[] args) {
    		rod();
    		top();
    		singleLine();
    		bottom();
    		rod();
    		middle();
    		middle();
    		middle();
    		middle(); 
    		top();
    		singleLine();  
    	 } 
    		  //Draw the rod
    		public static void rod() {
    		  for (int line = 1; line <= SIZE; line++) {
    		  	for (int i = 1; i <= 3*SIZE; i++)
    		  		System.out.print(" ");
    		   for (int i = 1; i <= line * 0 + 1; i++) 
            		System.out.print("||");
    				System.out.println("");
    	 }
    	 }
    		  //Draw the top
    		public static void top() {
        	          for (int line = 1; line <= SIZE; line++) {
        		    for (int i = 1; i <= -3 * line + 3*SIZE; i++)    
    		  		System.out.print(" ");
    		    for (int i = 1; i <= line * 0 + 1; i++) 
    		  		System.out.print("__/");
    		     for (int i = 1; i <= 3 * line - 3; i++) 
    				System.out.print(":");
    		     for (int i = 1; i <= line * 0 + 1; i++) 
    				System.out.print("||");
    		     for (int i = 1; i <= 3 * line - 3; i++) 
    				System.out.print(":");
    		     for (int i = 1; i <= line * 0 + 1; i++) 
    				System.out.print("\\__");
    		     for (int i = 1; i <= line * -3 + 12; i++)    
    		  		System.out.print(" ");
    				System.out.println("");
    	 }      
    	 }		 
      			//Drawing a line
    		public static void singleLine() {
    			for (int line = 1; line <= SIZE -3; line++) {
    				for (int i = 1; i <= 1; i++)
    					System.out.print("|");
    				for (int i = 1; i <= 3*SIZE; i++)	
    					System.out.print("\"\"");       
    	 			for (int i = 1; i <= 1; i++)	
    					System.out.print("|");
    					System.out.println("");
    	 }
    	 }
    	 		//Drawing the bottom
    	 	public static void bottom() {
    			 for (int line = 1; line <= SIZE; line++) {
    			    for (int i = 1; i <= -2 + (line*2)  ; i++) 
          	      System.out.print(" ");
            		 for (int i = 1; i <= 1*SIZE + -3 ; i++) 	
         	   		System.out.print("\\_");
    				 for (int i = 1; i <= line * -2 + 13; i++)  
                   System.out.print("/\\");
    				 for (int i = 1; i <= 1; i++)
                   System.out.print("_/");
    					System.out.println("");
    	 }
    	 }
    		  	//Drawing the middle
    		public static void middle() {
    			for (int line = 1; line <= SIZE; line++) { 		   
    				for (int i = 1; i <= SIZE*2 + 1; i++) 
    				System.out.print(" ");
    		 	  for (int i = 1; i <= line * 0 + 1; i++)
            System.out.print("|%%||%%|");
    		  System.out.println(" ");
    	 }
         }    
     }
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    What are loops like this one doing all over the place?

    [code=java]
    for (int i = 1; i <= line * 0 + 1; i++)
    [/code]

    kind regards,

    Jos

    Comment

    • Codeseeker99
      New Member
      • Jan 2008
      • 5

      #3
      Thanks I fixed that with the line but I still have the problem with changing the
      public static final int SIZE = 4; When I change it to public static final int SIZE = 3; or public static final int SIZE = 7; The image is messed up. can someone help me out?

      Comment

      Working...