Eine Größe von 5 ergibt:
Code: Select all
***** *****
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
***** *****
Code: Select all
public static void dia(int statSize, int size,int count) {
int statSizeLarge = (statSize*2)+1;
// Params:
// statSize == static size, never change this
// size == variable size, change this
// count == counter
if(size==0) {
System.out.println();
} else {
// is the counter smaller then the size
// if yes, increment and keep printing
if(count=statSizeLarge) {
count = 0;
System.out.println();
dia(statSize,size-1,count);
}
} // ends Else
}
Code: Select all
Enter commands:
diamond 3
******
** ****
* ****
* ****
** ****
* ****
* ****
Mobile version