Skip to content

Instantly share code, notes, and snippets.

@IshamMohamed
Created December 25, 2016 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IshamMohamed/81d99f49e1a33444b5a2b390b10fd26d to your computer and use it in GitHub Desktop.
Save IshamMohamed/81d99f49e1a33444b5a2b390b10fd26d to your computer and use it in GitHub Desktop.
Draws a very colorful Christmas tree with segments.
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