
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
C# | size: 1.32 KB | hits: 13 | expires: Never
using System;
namespace DrawPlotConsole
{
class MainClass
{
public static void Main (string[] args)
{
// Example of DrawPlot Console Function
while (true) {
Console.Clear ();
DrawPlot (0, 0, 10, 30, false);
System.Threading.Thread.Sleep (500);
Console.Clear ();
DrawPlot (1, 0, 10, 30, false);
System.Threading.Thread.Sleep (500);
}
// End of example
}
public static void DrawPlot (int X, int Y, int Height, int Width, bool fill)
{
Console.SetCursorPosition (X, Y);
int count = 0;
int lines = Height;
while (count < Width) {
Console.Write ("*");
count++;
}
int count2 = 0;
int i = 0;
while (count2 < lines) {
Console.WriteLine ("");
int a = 0;
while (a < X)
{
Console.Write (" ");
a++;
}
a = 0;
Console.Write ("*");
while (i < count - 2)
{
if (fill == true)
{
Console.Write ("*");
}
else
{
Console.Write (" ");
}
i++;
}
Console.Write ("*");
a = 0;
i = 0;
count2++;
}
Console.WriteLine ("");
int b = 0;
while (b < X)
{
Console.Write (" ");
b++;
}
count = 0;
while (count < Width) {
Console.Write ("*");
count++;
}
}
}
}