Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- abstract class Figure
- {
- protected int posX,posY;
- abstract public double Square();
- }
- class Triangle : Figure
- {
- int h, m;
- public Triangle(int h, int m)
- {
- this.h = h;
- this.m = m;
- }
- override public double Square()
- {
- return (h * m)/2;
- }
- }
- class Circle:Figure
- {
- int r;
- public Circle(int r)
- {
- this.r = r;
- }
- public override double Square()
- {
- return (Math.PI * r * r);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int r = 1;
- Figure circles = new Circle(r);
- Figure triangles = new Triangle(5, 10);
- Console.WriteLine("Площадь круга равна: " + circles.Square());
- Console.WriteLine("Площадь треугольника равна: " + triangles.Square());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement