Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Task1
  5. {
  6.     public interface IDraw
  7.     {
  8.         void Draw();
  9.     }
  10.  
  11.     public class DrawRectangle : IDraw
  12.     {
  13.         public void Draw()
  14.         {
  15.             Console.WriteLine("Это прямоугольник");
  16.         }
  17.     }
  18.  
  19.     public class DrawRing : IDraw
  20.     {
  21.         public void Draw()
  22.         {
  23.             Console.WriteLine("Это кольцо");
  24.         }
  25.     }
  26.  
  27.     public abstract class Figure
  28.     {
  29.         public abstract int X { get; set; }
  30.         public abstract int Y { get; set; }
  31.         public abstract string GetName();
  32.         public abstract void Draw();
  33.     }
  34.    
  35.     public class Ring : Figure
  36.     {
  37.         private IDraw IDraw { get; set; }
  38.         public override int X { get; set; }
  39.         public override int Y { get; set; }
  40.         public uint Radius { get; set; }
  41.         public Ring(int X,int Y,uint Radius,IDraw Draw)
  42.         {
  43.             this.X = X;
  44.             this.Y = Y;
  45.             this.Radius = Radius;
  46.             IDraw = Draw;
  47.         }
  48.  
  49.         public override void Draw()
  50.         {
  51.             IDraw.Draw();
  52.         }
  53.  
  54.         public override string GetName()
  55.         {
  56.             return "Ring";
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement