Advertisement
EntropyStarRover

java fort

Apr 19th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. /**
  2.  * Created by entropy on 4/19/2017.
  3.  */
  4. import java.util.Scanner;
  5. public class stronghold {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner (System.in);
  8.         int n = Integer.parseInt(scanner.nextLine());
  9.  
  10.         if (n>4){
  11.         String top = "/"+repeatString("^", n/2)+"\\"+repeatString("_", n/2)+"/"+repeatString("^", n/2)+"\\";
  12.         System.out.println(top);}
  13.  
  14.  
  15.         else {
  16.             String top = "/"+repeatString("^", n/2)+"\\"+"/"+repeatString("^", n/2)+"\\";
  17.             System.out.println(top);}
  18.  
  19.         if (n>4) {
  20.             for (int i = 0; i < n - 3; i++) {
  21.                 String middle = "|" + repeatString(" ", (2 * n) - 2) + ("|");
  22.                 System.out.println(middle);
  23.             }
  24.         } else {for (int i = 0; i < n - 2; i++) {
  25.                 String middle = "|" + repeatString(" ", 2 * n - 2) + ("|");
  26.                 System.out.println(middle);
  27.  
  28.             }
  29.         }
  30.  
  31.  
  32.         if (n>4){
  33.             String topBottom ="|"+repeatString(" ",n/2+1)+repeatString("_",n/2)+repeatString(" ",n/2+1)+"|";
  34.             System.out.println(topBottom);
  35.             String bottom = "\\"+repeatString("_", n/2)+"/"+repeatString(" ", n/2)+"\\"+repeatString("_", n/2)+"/";
  36.             System.out.println(bottom);}
  37.         else {
  38.             String bottom = "\\"+repeatString("_", n/2)+"/"+"\\"+repeatString("_", n/2)+"/";
  39.             System.out.println(bottom);}
  40.  
  41. } public static String repeatString (String str, int count) {
  42.     StringBuilder sb = new StringBuilder();
  43.     for (int i = 0; i <count ; i++) {
  44.         sb.append(str);
  45.     }
  46.         return sb.toString();
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement