NOTE: I need full code in C# with outputs for this program. Please read the full question first then answer accordingly.
Posted: Thu Jul 14, 2022 2:12 pm
NOTE: I need full code in C# with outputs for thisprogram. Please read the full question first then answeraccordingly. There is no hurry but I need an accurateanswer.
5. Dynamic Polymorphism -- use of keywords: abstract, override, interface (1) Give the definition of abstract class Shape and its subclasses -- Circle and cube. The test class is given below: public class Experiment2_5 \{ public static void Test() //or Main, if Program.cs (Containg Main meth does not exist! \{ 3 Shape s1= new Circle(); ((Circle)s1).R =2;// R is an automatic Property s1.Area(); s1.Volume (); Shape s2 = new Cube(); ((Cube)s2). SizeLength =2;// SizeLength is an automatic Property s2.Area (); s2.Volume(); \} A circle's area with the radius =2 is: 12.5663706143592. A circle's volume is: N/A A cube's surface area with the sizelength=2 is: 24. A cube's volume with the sizelength=2 is: 8. (2) We modify the class Shape in (1) to be non-abstract, and the methods Area () and volume () need to be changed from abstract to virtual. We need to keep the program function unchanged.
(3) Remove the definition of class Shape, and provide the definition of interfaces -- IArea and public class Experiment4c \{ public static void Main (){ IArea a1 = new Circle(); IArea a2 = new Cube(); ( Circle) a1)⋅R=2; ( Cube) a 2)⋅ SizeLength =2;
5. Dynamic Polymorphism -- use of keywords: abstract, override, interface (1) Give the definition of abstract class Shape and its subclasses -- Circle and cube. The test class is given below: public class Experiment2_5 \{ public static void Test() //or Main, if Program.cs (Containg Main meth does not exist! \{ 3 Shape s1= new Circle(); ((Circle)s1).R =2;// R is an automatic Property s1.Area(); s1.Volume (); Shape s2 = new Cube(); ((Cube)s2). SizeLength =2;// SizeLength is an automatic Property s2.Area (); s2.Volume(); \} A circle's area with the radius =2 is: 12.5663706143592. A circle's volume is: N/A A cube's surface area with the sizelength=2 is: 24. A cube's volume with the sizelength=2 is: 8. (2) We modify the class Shape in (1) to be non-abstract, and the methods Area () and volume () need to be changed from abstract to virtual. We need to keep the program function unchanged.
(3) Remove the definition of class Shape, and provide the definition of interfaces -- IArea and public class Experiment4c \{ public static void Main (){ IArea a1 = new Circle(); IArea a2 = new Cube(); ( Circle) a1)⋅R=2; ( Cube) a 2)⋅ SizeLength =2;