Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication49
- {
- class Program
- {
- static void Main(string[] args)
- {
- List <DrawingTool> tools = new List<DrawingTool>();
- DrawingTool pencil = new Pencil();
- tools.Add(pencil);
- DrawingTool brush = new Brush();
- tools.Add(brush);
- DrawingTool eraser = new Eraser();
- tools.Add(eraser);
- Console.WriteLine(tools[0].GetToolSize());
- }
- }
- abstract class DrawingTool
- {
- public virtual int GetToolSize()
- {
- return 0;
- }
- public virtual string GetColor()
- {
- return null;
- }
- public virtual string GetToolInfo()
- {
- return null;
- }
- }
- class Pencil : DrawingTool
- {
- public override int GetToolSize()
- {
- return 1;
- }
- }
- class Brush : DrawingTool
- {
- public override int GetToolSize()
- {
- return 6;
- }
- }
- class Eraser : DrawingTool
- {
- public override int GetToolSize()
- {
- return 3;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement