Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Sanduhr3 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- double triangleBaseLength = 9;
- char indentChar = '.';
- char fillChar = '+';
- int indentWidth = 0;
- int fillWidth =(int)triangleBaseLength;
- int triangleBaseHeight =(int)(triangleBaseLength / 2 + 0.5);
- int repeats = 5;
- int x=3;
- for(int vrepeats=0;vrepeats<x;vrepeats++) {//vertikale wiederholungen
- for(int i = 1; i <= 2 *triangleBaseHeight-1; i++) {//zeilen sanduhr
- for(int j = 1; j <= indentWidth; j++)
- if(i==triangleBaseHeight) {
- i=triangleBaseHeight+1;
- }else
- System.out.print(indentChar);
- for(int r = 1; r <= repeats; r++) {
- for(int j = 1; j <= fillWidth; j++)
- /*if(i==triangleBaseHeight) {
- fillWidth=1;
- }
- else*/
- System.out.print(fillChar);
- for(int j = 1; j <= 2 *indentWidth; j++)
- System.out.print(indentChar);
- }
- //if(i !=triangleBaseHeight)
- {System.out.println();}
- //else {;
- /*else {
- indentWidth -= 1;
- fillWidth += 2;
- System.out.println();
- }*/
- if(i <=triangleBaseHeight) {
- indentWidth += 1;
- fillWidth -= 2;
- }
- if(i >= triangleBaseHeight+1) {
- indentWidth -= 1;
- fillWidth += 2;
- }
- }
- }
- for(int j = 1; j <= 5*triangleBaseLength; j++)
- System.out.print(fillChar);
- }
- }
Add Comment
Please, Sign In to add comment