Advertisement
Gillito

Untitled

Jun 9th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 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 ConsoleApplication37
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int usrChoise;
  14.             List<Shape> lib = new List<Shape>();
  15.             Shape shape = new Shape();
  16.  
  17.             do
  18.             {
  19.                 Console.WriteLine("Создайте три фигуры.");
  20.                 Console.WriteLine("1) Квадрат");
  21.                 Console.WriteLine("2) Круг");
  22.                 Console.WriteLine("3) Треугольник");
  23.                 Console.WriteLine("4) Выход \n");
  24.                 usrChoise = int.Parse(Console.ReadLine());
  25.  
  26.                 if (usrChoise == 1)
  27.                 {
  28.                     Console.WriteLine("Введите сторону квадрата, чтобы получить его площадь");
  29.                     int a = int.Parse(Console.ReadLine());
  30.                     Shape sqr = new Square(a);
  31.                     lib.Add(sqr);
  32.                 }
  33.  
  34.                 else if (usrChoise == 2)
  35.                 {
  36.                     Console.WriteLine("Введите радиус круга, чтобы получить его площадь");
  37.                     int a = int.Parse(Console.ReadLine());
  38.                     Shape sqr = new Circle(a);
  39.                     lib.Add(sqr);
  40.                 }
  41.  
  42.                 else if (usrChoise == 3)
  43.                 {
  44.                     Console.WriteLine("Введите основание и высоту треугольника, чтобы получить его площадь");
  45.                     int a = int.Parse(Console.ReadLine());
  46.                     int h = int.Parse(Console.ReadLine());
  47.                     Shape sqr = new Triangle(a, h);
  48.                     lib.Add(sqr);
  49.                 }
  50.  
  51.                 else Console.WriteLine("Сделайте допустимый выбор.");
  52.             }
  53.             while (usrChoise != 4);
  54.         }
  55.     }
  56.  
  57.     class Shape
  58.     {
  59.         public virtual double GetSquare()
  60.         {
  61.             return 0;
  62.         }
  63.     }
  64.  
  65.     class Square : Shape
  66.     {
  67.         public int a;
  68.         public Square(int b)
  69.         {
  70.             a = b;
  71.         }
  72.        
  73.     }
  74.  
  75.     class Circle : Shape
  76.     {
  77.         public int rad;
  78.         public Circle(int r)
  79.         {
  80.             rad = r;
  81.         }
  82.     }
  83.  
  84.     class Triangle : Shape
  85.     {
  86.         public int a, h;
  87.         public Triangle(int aa, int hh)
  88.         {
  89.             a = aa;
  90.             h = hh;
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement