*
***
*****
*******
*********
***********
*********
*******
*****
***
*
|
Print all the classic star patterns in your console with a few loops ☆*: .。. o(≧▽≦)o .。.:*☆
This repository gathers small Java programs that each draw a star (*) pattern in the console using nested loops: triangles, pyramids, diamonds, squares and more!!! Every pattern is a standalone class with its own main method and no dependencies. (o゜▽゜)o☆
Clone the repo, compile all the classes with a JDK (8 or later), then run the pattern you want by its class name:
javac -d out src/*.javajava -cp out DiamondStarChange the size of any pattern by editing the public static constants at the top of its class (NB_LINES, NB_COLUMNS, SIDE_LENGTH, WIDTH, LENGTH), then recompile. For centered shapes, keep NB_COLUMNS equal to 2 * NB_LINES - 1 so the pattern stays symmetric.
LeftTriangleStar |
RightTriangleStar |
ReverseLeftTriangleStar |
ReverseRightTriangleStar |
|---|---|---|---|
* ** *** **** ***** |
* ** *** **** ***** |
***** **** *** ** * |
*****
****
***
**
*
|
PyramidStar |
ReversePyramidStar |
PyramidSpaceStar |
|---|---|---|
*
***
*****
*******
*********
|
***********
*********
*******
*****
***
*
|
*
* *
* * *
* * * *
* * * * *
|
HollowPyramidStar |
ReverseHollowPyramidStar |
|---|---|
* * * * * * * ********* |
***********
* *
* *
* *
* *
*
|
DiamondStar |
HollowDiamondStar |
HalfDiamondStar |
ReverseHalfDiamondStar |
|---|---|---|---|
*
***
*****
*******
*********
***********
*********
*******
*****
***
*
|
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
|
* ** *** **** ***** **** *** ** * |
***** **** *** ** * ** *** **** ***** |
SquareStar |
HollowSquareStar |
|---|---|
***** ***** ***** ***** ***** |
***** * * * * * * ***** |
RectangleStar |
HollowRectangleStar |
|---|---|
******************** ******************** ******************** ******************** ******************** |
******************** * * * * * * ******************** |
PlusStar |
|---|
*
*
*********
*
*
|
star_trees
│
├── src/
│ ├── LeftTriangleStar.java
│ ├── RightTriangleStar.java
│ ├── ReverseLeftTriangleStar.java
│ ├── ReverseRightTriangleStar.java
│ ├── PyramidStar.java
│ ├── ReversePyramidStar.java
│ ├── PyramidSpaceStar.java
│ ├── HollowPyramidStar.java
│ ├── ReverseHollowPyramidStar.java
│ ├── DiamondStar.java
│ ├── HollowDiamondStar.java
│ ├── HalfDiamondStar.java
│ ├── ReverseHalfDiamondStar.java
│ ├── SquareStar.java
│ ├── HollowSquareStar.java
│ ├── RectangleStar.java
│ ├── HollowRectangleStar.java
│ └── PlusStar.java
│
├── README.md
├── LICENSE.md
└── .gitignore
Licensed under MIT License. For further information, see the LICENSE file.
Made with ❤️ by SalimMc
⭐ If this repository helped you, you know what to do!