Created
December 25, 2016 14:30
-
-
Save IshamMohamed/81d99f49e1a33444b5a2b390b10fd26d to your computer and use it in GitHub Desktop.
Draws a very colorful Christmas tree with segments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ColorfulChristmasTree | |
{ | |
class Program | |
{ | |
const int HEIGHT = 5; | |
const int SEGMENTS = 4; | |
static void Main(string[] args) | |
{ | |
MakeTree(); | |
Console.ReadKey(); | |
} | |
public static void MakeTree() | |
{ | |
Random foreColor = new Random(); | |
int start = 2 * HEIGHT + 2 * SEGMENTS - 3; | |
for (int i = 1; i <= SEGMENTS; i++) | |
{ | |
for (int line = 1; line <= HEIGHT; line++) | |
{ | |
string initiator = ""; | |
for (int j = 1; j <= 2 * line + 2 * i - 3; j++) | |
{ | |
initiator += "*"; | |
} | |
for (int space = 0; space <= start - (HEIGHT + line + i); space++) | |
{ | |
initiator = " " + initiator; | |
} | |
Console.ForegroundColor = (ConsoleColor)foreColor.Next(7,14); | |
Console.WriteLine(initiator); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment