using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CAInheritance_AbstractApp
{
abstract class Figure
{
public int dimension;
public abstract double Area();
public abstract double Perimeter();
}
class Square : Figure
{
public override double Area()
{
return dimension * dimension;
}
public override double Perimeter()
{
return 4 * dimension;
}
}
class Circle : Figure
{
public override double Area()
{
return Math.PI * dimension * dimension;
}
public override double Perimeter()
{
return 2 *Math.PI* dimension;
}
}
class AbstractApp
{
static void Main(string[] args)
{
Figure fi = new Square();
fi.dimension = 10;
Console.WriteLine(fi.Area());
Console.WriteLine(fi.Perimeter());
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CAInheritance_AbstractApp
{
abstract class Figure
{
public int dimension;
public abstract double Area();
public abstract double Perimeter();
}
class Square : Figure
{
public override double Area()
{
return dimension * dimension;
}
public override double Perimeter()
{
return 4 * dimension;
}
}
class Circle : Figure
{
public override double Area()
{
return Math.PI * dimension * dimension;
}
public override double Perimeter()
{
return 2 *Math.PI* dimension;
}
}
class AbstractApp
{
static void Main(string[] args)
{
Figure fi = new Square();
fi.dimension = 10;
Console.WriteLine(fi.Area());
Console.WriteLine(fi.Perimeter());
Console.ReadLine();
}
}
}
No comments:
Post a Comment