Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- public abstract class Solid
- {
- abstract public double Volume();
- abstract public double Surface();
- }
- public abstract class Polyhedron : Solid
- {
- public int faces;
- public int edges;
- public int vertices;
- }
- public class Cuboid : Polyhedron
- {
- public int a, b, c;
- public Cuboid(int _a, int _b, int _c)
- {
- a = _a;
- b = _b;
- c = _c;
- }
- public override double Surface()
- {
- //2(ab + ac + bc)
- return 2 * (a * b + a * c + b*c );
- }
- public override double Volume()
- {
- return a * b * c;
- }
- public override string ToString()
- {
- return " Volume = " + Volume() + " Surface = " + Surface();
- }
- }
- public class Cube : Cuboid
- {
- public Cube(int _a)
- {
- a = _a;
- }
- public override double Surface()
- {
- return 6 * (a * a);
- }
- public override double Volume()
- {
- return (a * a * a);
- }
- }
- public class Sphere : Solid
- {
- public double R;
- public override double Surface()
- {
- return 4 * Math.PI * (R * R);
- }
- public override double Volume()
- {
- return 1.33 * Math.PI * (R * R * R);
- }
- }
- public class Cone : Solid
- {
- public double R, L, H;
- public override double Surface()
- {
- return Math.PI * (R * R) + Math.PI * R * L;
- }
- public override double Volume()
- {
- return 0.33 * Math.PI * (R * R) * H;
- }
- }
- public class Cylinder : Solid
- {
- public override double Surface()
- {
- throw new NotImplementedException();
- }
- public override double Volume()
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement