Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program.cs
- using System;
- namespace EXP2
- {
- public abstract class Shape
- {
- public abstract double CalculateArea();
- public abstract double ShapeDetails();
- }
- public class Rectangle : Shape
- {
- private double length;
- private double breadth;
- public Rectangle(double length, double breadth)
- {
- this.length = length;
- this.breadth = breadth;
- }
- public override double CalculateArea()
- {
- return length * breadth;
- }
- public override double ShapeDetails()
- {
- // Implement details specific to Rectangle
- Console.WriteLine("Details of Rectangle:");
- Console.WriteLine("Length: " + length);
- Console.WriteLine("Breadth: " + breadth);
- return 0;
- }
- }
- class CodeFile1
- {
- static void Main(string[] args)
- {
- Shape obj = new Rectangle(2, 3);
- double area = obj.CalculateArea();
- Console.WriteLine("Area of Rectangle: " + area);
- double details = obj.ShapeDetails();
- Console.WriteLine("Details: ");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement