Advertisement
Guest User

DrawFortress

a guest
Mar 4th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package Week6LoopDrawings;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Stronghold {
  6. public static void main(String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8. int n = Integer.parseInt(scan.nextLine());
  9.  
  10. //top part
  11.  
  12. String firstrow1 ="/" + repeatStr("^",n/2)
  13. + "\\" ;
  14. String firstrow2 = repeatStr("_",n/2);
  15.  
  16. String firstrow3 = firstrow1;
  17. if (n >= 5){
  18. System.out.println(firstrow1 + firstrow2 + firstrow3);
  19. }else {
  20. System.out.println(firstrow1 + firstrow3);
  21. }
  22. // middle part
  23.  
  24. String middlerow = "|" + repeatStr(" ",2*n - 2) + "|";
  25. String middlerow2 = "|" + repeatStr(" ",n/2+1)
  26. + repeatStr("_",n/2)
  27. + repeatStr(" ",n/2+1)
  28. + "|";
  29. for (int i = 1; i < n - 2 ; i++) {
  30. System.out.println(middlerow);
  31. }
  32. if (n > 4){
  33. System.out.println(middlerow2);
  34. }
  35. else System.out.println(middlerow);
  36.  
  37. //bottom part
  38.  
  39. String downrow1 = "\\" + repeatStr("_",n/2)
  40. + "/" ;
  41. String downrow2 = repeatStr(" ",n/2);
  42. String downrow3 = downrow1;
  43. if (n >= 5){
  44. System.out.println(downrow1 + downrow2 + downrow3);
  45. }else {
  46. System.out.println(downrow1 + downrow3);
  47. }
  48.  
  49.  
  50.  
  51. }
  52.  
  53. static String repeatStr (String strToRepeat,int count){
  54. String text = "";
  55. for (int i = 0; i < count; i++) {
  56. text += strToRepeat;
  57. }
  58. return text;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement