Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: C#  |  size: 1.32 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2.  
  3. namespace DrawPlotConsole
  4. {
  5.         class MainClass
  6.         {
  7.                 public static void Main (string[] args)
  8.                 {
  9.  
  10.                         // Example of DrawPlot Console Function
  11.                         while (true) {
  12.                                 Console.Clear ();
  13.                                 DrawPlot (0, 0, 10, 30, false);
  14.                                 System.Threading.Thread.Sleep (500);
  15.                                 Console.Clear ();
  16.                                 DrawPlot (1, 0, 10, 30, false);
  17.                                 System.Threading.Thread.Sleep (500);
  18.                         }
  19.                         // End of example
  20.  
  21.                 }
  22.  
  23.                 public static void DrawPlot (int X, int Y, int Height, int Width, bool fill)
  24.                 {
  25.             Console.SetCursorPosition (X, Y);
  26.                         int count = 0;
  27.                         int lines = Height;
  28.                         while (count < Width) {
  29.                                 Console.Write ("*");
  30.                                 count++;
  31.                         }
  32.                         int count2 = 0;
  33.                         int i = 0;
  34.                         while (count2 < lines) {
  35.                                 Console.WriteLine ("");
  36.                                 int a = 0;
  37.  
  38.                                 while (a < X)
  39.                                 {
  40.                                 Console.Write (" ");
  41.                                         a++;
  42.                                 }
  43.                                 a = 0;
  44.                                 Console.Write ("*");
  45.  
  46.                                 while (i < count - 2)
  47.                                 {
  48.                                         if (fill == true)
  49.                                         {
  50.                                         Console.Write ("*");
  51.                                         }
  52.                                         else
  53.                                         {
  54.                                         Console.Write (" ");
  55.                                         }
  56.                                         i++;
  57.                                 }
  58.                                 Console.Write ("*");
  59.                                 a = 0;
  60.                                 i = 0;
  61.                                 count2++;
  62.                         }
  63.                         Console.WriteLine ("");
  64.                         int b = 0;
  65.                                 while (b < X)
  66.                                 {
  67.                                 Console.Write (" ");
  68.                                         b++;
  69.                                 }
  70.                         count = 0;
  71.                         while (count < Width) {
  72.                                 Console.Write ("*");
  73.                                 count++;
  74.                         }
  75.         }
  76. }
  77. }