Advertisement
pdaogu

CONSTRUCTOR

Apr 15th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 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 Polymorphism
  8. {
  9.     class Window
  10.     {
  11.         protected int top, left, bottom, right;
  12.         public Window(int top, int left, int bottom, int right)
  13.         {
  14.             this.top = top;
  15.             this.left = left;
  16.             this.bottom = bottom;
  17.             this.right = right;
  18.         }
  19.         public Window() { }
  20.         public virtual void DrawWindow()
  21.         {
  22.             Console.WriteLine("Window is drawn at (({0}, {1}), ({2}, {3}))", this.top, this.left, this.bottom, this.right);
  23.         }
  24.     }
  25.  
  26.     class Dialog : Window
  27.     {
  28.         public Dialog(int top, int left, int bottom, int right)
  29.         {
  30.  
  31.         }
  32.         public new void DrawWindow()
  33.         {
  34.             Console.WriteLine("Dialog is drawn at (({0}, {1}), ({2}, {3}))", this.top, this.left, this.bottom, this.right);
  35.         }
  36.     }
  37.     class Program
  38.     {
  39.         static void Main(string[] args)
  40.         {
  41.             Window d1 = new Dialog(1, 2, 3, 4);
  42.             Dialog d2 = new Dialog(5, 6, 7, 8);
  43.             d1.DrawWindow();
  44.             d2.DrawWindow();
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement