Advertisement
Gillito

Untitled

Jun 18th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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 ConsoleApplication49
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List <DrawingTool> tools = new List<DrawingTool>();
  14.  
  15.             DrawingTool pencil = new Pencil();
  16.             tools.Add(pencil);
  17.             DrawingTool brush = new Brush();
  18.             tools.Add(brush);
  19.             DrawingTool eraser = new Eraser();
  20.             tools.Add(eraser);
  21.  
  22.             Console.WriteLine(tools[0].GetToolSize());
  23.  
  24.         }
  25.     }
  26.  
  27.     abstract class DrawingTool
  28.     {
  29.         public virtual int GetToolSize()
  30.         {
  31.             return 0;
  32.         }
  33.  
  34.         public virtual string GetColor()
  35.         {
  36.             return null;
  37.         }
  38.  
  39.         public virtual string GetToolInfo()
  40.         {
  41.             return null;
  42.         }
  43.  
  44.     }
  45.  
  46.     class Pencil : DrawingTool
  47.     {
  48.         public override int GetToolSize()
  49.         {
  50.                 return 1;
  51.         }
  52.     }
  53.  
  54.     class Brush : DrawingTool
  55.     {
  56.         public override int GetToolSize()
  57.         {
  58.                 return 6;
  59.         }
  60.     }
  61.  
  62.     class Eraser : DrawingTool
  63.     {
  64.         public override int GetToolSize()
  65.         {
  66.                 return 3;
  67.         }
  68.     }
  69.  
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement