filmov
tv
C# Programming Challenge 12.10: Shape Inheritance Hierarchy

Показать описание
Visual C# 2012 How to Program
C# Programming Challenge 12.10: Shape Hierarchy (C# OOP, C# abstract classes, C# inheritance, C# polymorphism)
Implement the Shape hierarchy. Each TwoDimensionalShape should contain read-only abstract property Area to calculate the area of the two-dimensional shape.
Each ThreeDimensionalShape should have read-only abstract properties Area and Volume to calculate the surface area and volume, respectively, of the three-dimensional shape.
Create an app that uses an array of Shape references to objects of each concrete class in the hierarchy. Display a text description of the object to which each array element refers. Also, in the loop that processes all the shapes in the array, determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, display its area. If a shape is a ThreeDimensionalShape, display its area and volume.
Learning to code? Follow my C# tutorials for beginners. I do a lot of C# programming challenges and C# projects as part of my homework - every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don't forget to subscribe, as I release new programming videos every day!
C# Programming Challenge 12.10: Shape Hierarchy (C# OOP, C# abstract classes, C# inheritance, C# polymorphism)
Implement the Shape hierarchy. Each TwoDimensionalShape should contain read-only abstract property Area to calculate the area of the two-dimensional shape.
Each ThreeDimensionalShape should have read-only abstract properties Area and Volume to calculate the surface area and volume, respectively, of the three-dimensional shape.
Create an app that uses an array of Shape references to objects of each concrete class in the hierarchy. Display a text description of the object to which each array element refers. Also, in the loop that processes all the shapes in the array, determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, display its area. If a shape is a ThreeDimensionalShape, display its area and volume.
Learning to code? Follow my C# tutorials for beginners. I do a lot of C# programming challenges and C# projects as part of my homework - every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don't forget to subscribe, as I release new programming videos every day!
Комментарии