Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Example
- {
- interface Shape
- {
- void getData(int l, int b);
- void displayArea();
- }
- class Rectangle : Shape
- {
- private int l;
- private int b;
- public void getData(int l, int b)
- {
- this.l = l;
- this.b = b;
- }
- public void displayArea(){
- Console.WriteLine(l*b);
- }
- }
- class Square : Shape
- {
- private int l;
- public void getData(int l, int b = 0)
- {
- this.l = l;
- }
- public void displayArea(){
- Console.WriteLine(l*l);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Rectangle r = new Rectangle();
- r.getData(5,4);
- r.displayArea();
- Square s = new Square();
- s.getData(5);
- s.displayArea();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement