Помогите с решением задачи на наследование
1)Не могу понять как найти круг с меньшим среднего.
2)Конус не наследует поля(значения) из круга.
3)не могу вывести больший по объёму конус.
задание :
Создать класс окружность, член класса – радиус R. Предусмотреть в классе методы вычисления и вывода сведений о фигуре – площади, длины окружности. Создать производный класс – конус с высотой h, добавить в класс метод определения объема фигуры, перегрузить методы расчета площади и вывода сведений о фигуре.Написать программу, демонстрирующую работу с классом: дано N окружностей и M конусов, найти количество окружностей, у которых площадь меньше средней площади всех окружностей, и наибольший по объему конус.
namespace NasledovanieNum2
{
class Circle
{
// Поля
protected double radius;
protected double length;
protected double square;
public void InputCircle()
{
try
{
Console.WriteLine("Введите радиус:");
Radius = double.Parse(Console.ReadLine());
Console.WriteLine("Введите длину:");
Length = double.Parse(Console.ReadLine());
Console.WriteLine("Введите площадь:");
Square = double.Parse(Console.ReadLine());
}
catch {
Console.WriteLine("Вводите числа, а не иные символы");
}
}
// Свойства
public double Radius
{
get { return radius; }
set { radius = (value > 0.0) ? value : 0.0; }
}
public double Length
{
get { return length; }
set { length = (value > 0.0) ? value : 0.0; }
}
public double Square
{
get { return square; }
set { square = (value > 0.0) ? value : 0.0; }
}
// Конструкторы
public Circle()
{
radius = 0.0;
length = 0.0;
square = 0.0;
}
public Circle(double radius, double length, double square)
{
Radius = radius;
Length = length;
Square = square;
}
// Методы
public double CalculateSquare()
{
return Math.PI * Math.Pow(radius, 2);
}
public double CalculateLength()
{
return 2 * Math.PI * radius;
}
public void DisplayInfo()
{
Console.WriteLine("Радиус: {0}, Длина: {1}, Площадь: {2}", radius, length, square);
Console.WriteLine("Вычисление площади: {0}", CalculateSquare());
Console.WriteLine("Вычисление длины: {0}", CalculateLength());
}
}
class Cone : Circle
{
// Поле
protected double height;
// Свойство
public double Height
{
get { return height; }
set { height = (value > 0.0) ? value : 0.0; }
}
// Конструкторы
public Cone() : base()
{
height = 0.0;
}
public Cone(double radius, double length, double square, double height) : base(radius, length, square)
{
Height = height;
}
// Методы
public double CalculateVolume()
{
return (Math.PI * Math.Pow(Radius, 2) * Height) / 3;
}
public void Input()
{
Console.WriteLine("Введите высоту конуса:");
Height = double.Parse(Console.ReadLine());
}
public void PassportCone()
{
base.DisplayInfo();
Console.WriteLine("Высота конуса: {0}", height);
Console.WriteLine("Объём конуса: {0}", CalculateVolume());
}
}
internal class Program
{
static Cone[] CreateConeArray(int coneSize)
{
Cone[] cones = new Cone[coneSize];
Console.WriteLine("Введите число конусов:");
for (int i = 0; i < coneSize; i++)
{
cones[i] = new Cone();
cones[i].Input(); // Вызываем метод Input объекта Cone для ввода данных о конусе
}
return cones;
}
static Circle[] CreateCircleArray(int size)
{
Circle[] circles = new Circle[size];
for (int i = 0; i < size; i++)
{
circles[i] = new Circle();
circles[i].InputCircle();
}
return circles;
}
static void DisplayCircleArray(Circle[] circles)
{
Console.WriteLine("Круги:\n");
foreach (Circle circle in circles)
{
circle.DisplayInfo();
Console.WriteLine();
}
}
static double CalculateAverageSquare(Circle[] circles)
{
double sum = 0.0;
foreach (Circle circle in circles)
{
sum += circle.Square;
}
return sum / circles.Length;
}
static int CountCirclesWithSmallerSquare(Circle[] circles)
{
double averageSquare = CalculateAverageSquare(circles);
int count = 0;
foreach (Circle circle in circles)
{
if (circle.Square < averageSquare)
{
count++;
}
}
return count;
}
static Cone FindLargestVolumeCone(Cone[] cones)
{
Cone largestCone = cones[0];
foreach (Cone cone in cones)
{
if (cone.CalculateVolume() > largestCone.CalculateVolume())
{
largestCone = cone;
}
}
return largestCone;
}
static void Main(string[] args)
{
Console.WriteLine("Введите число кругов:");
int circleSize = int.Parse(Console.ReadLine());
Circle[] circles = CreateCircleArray(circleSize);
DisplayCircleArray(circles);
Console.WriteLine("\nКоличество окружностей с площадью меньше средней: {0}", CountCirclesWithSmallerSquare(circles));
Console.WriteLine("\nВведите число конусов:");
int coneSize = int.Parse(Console.ReadLine());
Cone[] cones = CreateConeArray(coneSize);
Cone largestVolumeCone = FindLargestVolumeCone(cones);
Console.WriteLine("\nНаибольший по объему конус:");
largestVolumeCone.PassportCone();
Console.ReadKey();
}
}
}