Guest User

Untitled

a guest
Nov 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public class Sanduhr3 {
  2.  
  3. public static void main(String[] args) {
  4. // TODO Auto-generated method stub
  5. double triangleBaseLength = 9;
  6. char indentChar = '.';
  7. char fillChar = '+';
  8. int indentWidth = 0;
  9. int fillWidth =(int)triangleBaseLength;
  10. int triangleBaseHeight =(int)(triangleBaseLength / 2 + 0.5);
  11. int repeats = 5;
  12. int x=3;
  13. for(int vrepeats=0;vrepeats<x;vrepeats++) {//vertikale wiederholungen
  14. for(int i = 1; i <= 2 *triangleBaseHeight-1; i++) {//zeilen sanduhr
  15.  
  16. for(int j = 1; j <= indentWidth; j++)
  17. if(i==triangleBaseHeight) {
  18. i=triangleBaseHeight+1;
  19. }else
  20. System.out.print(indentChar);
  21.  
  22. for(int r = 1; r <= repeats; r++) {
  23. for(int j = 1; j <= fillWidth; j++)
  24. /*if(i==triangleBaseHeight) {
  25. fillWidth=1;
  26. }
  27. else*/
  28. System.out.print(fillChar);
  29.  
  30. for(int j = 1; j <= 2 *indentWidth; j++)
  31.  
  32.  
  33. System.out.print(indentChar);
  34. }
  35. //if(i !=triangleBaseHeight)
  36. {System.out.println();}
  37.  
  38.  
  39.  
  40.  
  41. //else {;
  42.  
  43. /*else {
  44. indentWidth -= 1;
  45. fillWidth += 2;
  46. System.out.println();
  47. }*/
  48.  
  49. if(i <=triangleBaseHeight) {
  50. indentWidth += 1;
  51. fillWidth -= 2;
  52. }
  53. if(i >= triangleBaseHeight+1) {
  54. indentWidth -= 1;
  55. fillWidth += 2;
  56.  
  57. }
  58.  
  59. }
  60. }
  61. for(int j = 1; j <= 5*triangleBaseLength; j++)
  62. System.out.print(fillChar);
  63. }
  64.  
  65. }
Add Comment
Please, Sign In to add comment