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 Polymorphism
- {
- class Window
- {
- protected int top, left, bottom, right;
- public Window (int top, int left, int bottom, int right)
- {
- this.top = top;
- this.left = left;
- this.bottom = bottom;
- this.right = right;
- }
- public virtual void DrawWindow ()
- {
- Console.WriteLine("Window is drawn at (({0}, {1}), ({2}, {3}))", this.top, this.left, this.bottom, this.right);
- }
- }
- class Dialog : Window
- {
- public Dialog (int top, int left, int bottom, int right): base(top, left, bottom, right)
- {
- }
- public new void DrawWindow ()
- {
- Console.WriteLine("Dialog is drawn at (({0}, {1}), ({2}, {3}))", this.top, this.left, this.bottom, this.right);
- }
- }
- class Program
- {
- static void Main(string[] args) {
- Window d1 = new Dialog(1, 2, 3, 4);
- Dialog d2 = new Dialog(5, 6, 7, 8);
- d1.DrawWindow();
- d2.DrawWindow();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement