Advertisement
dimipan80

Exam 1. Drawing_Sunglasses

Jun 1st, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.03 KB | None | 0 0
  1. namespace _17.Sunglasses
  2. {
  3.     using System;
  4.  
  5.     public class DrawSunglasses
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             checked
  10.             {
  11.                 // Enter and read height of sunglasses, always an odd number:
  12.                 byte numN = byte.Parse(Console.ReadLine());
  13.                
  14.                 // Calculating number (width) of Frames:
  15.                 byte countFrames = (byte)(2 * numN);
  16.  
  17.                 // Calculating number (width) of Lenses:
  18.                 byte countLenses = (byte)(countFrames - 2);
  19.  
  20.                 // Create string for Top or Bottom row Frame:
  21.                 string topBottomFrame = new string('*', countFrames);
  22.  
  23.                 // Create string for Whitespace on row between Left and Right Frames:
  24.                 string whitespaceBetweenFrames = new string(' ', numN);
  25.  
  26.                 // Create string for Lens on row:
  27.                 string lens = new string('/', countLenses);
  28.                 lens = '*' + lens + '*';
  29.  
  30.                 // Create string for Bridge between Left and Right Frames on middle row:
  31.                 string bridge = new string('|', numN);
  32.  
  33.                 // Print created strings and drawing Sunglasses:
  34.                 for (int row = 0; row < numN; row++)
  35.                 {
  36.                     if (row == 0 || row == numN - 1)
  37.                     {
  38.                         // Print Frames on Top and Bottom row:
  39.                         Console.WriteLine("{0}{1}{0}", topBottomFrame, whitespaceBetweenFrames);
  40.                     }
  41.                     else if (row == numN / 2)
  42.                     {
  43.                         // Print Frames and Bridge on middle row:
  44.                         Console.WriteLine("{0}{1}{0}", lens, bridge);
  45.                     }
  46.                     else
  47.                     {
  48.                         // Print Lenses on other rows:
  49.                         Console.WriteLine("{0}{1}{0}", lens, whitespaceBetweenFrames);
  50.                     }
  51.                 }
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement