Advertisement
vvccs

EXP2

Apr 12th, 2024 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. //Program.cs
  2. using System;
  3.  
  4. namespace EXP2
  5. {
  6. public abstract class Shape
  7. {
  8. public abstract double CalculateArea();
  9. public abstract double ShapeDetails();
  10. }
  11.  
  12. public class Rectangle : Shape
  13. {
  14. private double length;
  15. private double breadth;
  16.  
  17. public Rectangle(double length, double breadth)
  18. {
  19. this.length = length;
  20. this.breadth = breadth;
  21. }
  22.  
  23. public override double CalculateArea()
  24. {
  25. return length * breadth;
  26. }
  27.  
  28. public override double ShapeDetails()
  29. {
  30. // Implement details specific to Rectangle
  31. Console.WriteLine("Details of Rectangle:");
  32. Console.WriteLine("Length: " + length);
  33. Console.WriteLine("Breadth: " + breadth);
  34. return 0;
  35. }
  36. }
  37.  
  38. class CodeFile1
  39. {
  40. static void Main(string[] args)
  41. {
  42. Shape obj = new Rectangle(2, 3);
  43. double area = obj.CalculateArea();
  44. Console.WriteLine("Area of Rectangle: " + area);
  45.  
  46. double details = obj.ShapeDetails();
  47. Console.WriteLine("Details: ");
  48. Console.ReadLine();
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement