Advertisement
Mitax

Tetris

Feb 5th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _3.Tetris
  8. {
  9.     class Tetris
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             string currentDirection = Console.ReadLine();
  15.  
  16.             while (currentDirection != "exit")
  17.             {
  18.                 switch (currentDirection)
  19.                 {
  20.                     case "up":       Up(n);       break;
  21.                     case "down":     Down(n);     break;
  22.                     case "left":     Left(n);     break;
  23.                     case "right":    Right(n);    break;
  24.                 }
  25.                 currentDirection = Console.ReadLine();
  26.             }
  27.         }
  28.  
  29.         static void Left(int n)
  30.         {
  31.             for (int i = 0; i < n; i++)
  32.             {
  33.                 Console.WriteLine(new string('.', n) + new string('*', n));
  34.             }
  35.  
  36.             for (int i = 0; i < n; i++)
  37.             {
  38.                 Console.WriteLine(new string('*', 2 * n));
  39.             }
  40.  
  41.             for (int i = 0; i < n; i++)
  42.             {
  43.                 Console.WriteLine(new string('.', n) + new string('*', n));
  44.             }
  45.         }
  46.  
  47.         static void Right(int n)
  48.         {
  49.             for (int i = 0; i < n; i++)
  50.             {
  51.                 Console.WriteLine(new string('*', n) + new string('.', n));
  52.             }
  53.  
  54.             for (int i = 0; i < n; i++)
  55.             {
  56.                 Console.WriteLine(new string('*', 2 * n));
  57.             }
  58.  
  59.             for (int i = 0; i < n; i++)
  60.             {
  61.                 Console.WriteLine(new string('*', n) + new string('.', n));
  62.             }
  63.         }
  64.  
  65.         static void Up(int n)
  66.         {
  67.             for (int i = 0; i < n; i++)
  68.             {
  69.                 Console.WriteLine(new string('.', n)+ new string('*', n)+ new string('.', n));
  70.             }
  71.  
  72.             for (int i = 0; i < n; i++)
  73.             {
  74.                 Console.WriteLine(new string('*', n * 3));
  75.             }
  76.         }
  77.  
  78.         static void Down(int n)
  79.         {
  80.             for (int i = 0; i < n; i++)
  81.             {
  82.                 Console.WriteLine(new string('*', n * 3));
  83.             }
  84.  
  85.             for (int i = 0; i < n; i++)
  86.             {
  87.                 Console.WriteLine( new string('.', n) + new string('*', n) + new string('.', n));
  88.             }
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement