Загрузка данных


using System;

namespace RocketsLab
{
    // Интерфейсы
    public interface IMakeSound
    {
        void MakeSound();   // "звук" двигателя / старта
    }

    public interface IMove
    {
        void Move();        // движение / полёт
    }

    // === Классы ракет ===

    public class Falcon9 : IMakeSound, IMove
    {
        public string Name { get; set; }
        public string Company { get; set; } = "SpaceX";

        public Falcon9(string name)
        {
            Name = name;
        }

        public void MakeSound()
        {
            Console.WriteLine($"{Name} издаёт звук: РРРРРРРРРРР!!! (рев двигателей Merlin)");
        }

        public void Move()
        {
            Console.WriteLine($"{Name} летит: мощный вертикальный старт с возвращаемой первой ступенью");
        }

        public void Draw()
        {
            Console.WriteLine("       ^");
            Console.WriteLine("      / \\");
            Console.WriteLine("     /   \\");
            Console.WriteLine("    /     \\");
            Console.WriteLine("   /  F9   \\");
            Console.WriteLine("  /_________\\");
            Console.WriteLine("  |  ████   |");
            Console.WriteLine("  |  ████   |");
            Console.WriteLine("  |_________|");
            Console.WriteLine("     |||||");
            Console.WriteLine("     |||||");
        }

        public void DisplayInfo()
        {
            Draw();
            Console.WriteLine($"Ракета: {Name}");
            Console.WriteLine($"Производитель: {Company}");
            MakeSound();
            Move();
        }
    }

    public class Starship : IMakeSound, IMove
    {
        public string Name { get; set; }
        public string Company { get; set; } = "SpaceX";
        public int PayloadCapacity { get; set; } = 150; // тонн на низкую орбиту

        public Starship(string name)
        {
            Name = name;
        }

        public void MakeSound()
        {
            Console.WriteLine($"{Name} издаёт звук: ГРОМОВОЙ РЁВ Raptor-ов!!!");
        }

        public void Move()
        {
            Console.WriteLine($"{Name} летит: полностью многоразовая сверхтяжёлая ракета к Марсу");
        }

        public void Draw()
        {
            Console.WriteLine("        ▲");
            Console.WriteLine("       / \\");
            Console.WriteLine("      /   \\");
            Console.WriteLine("     /  S  \\");
            Console.WriteLine("    /  T A R \\");
            Console.WriteLine("   /  S H I P \\");
            Console.WriteLine("  /____________\\");
            Console.WriteLine("  |   ██████   |");
            Console.WriteLine("  |   ██████   |");
            Console.WriteLine("  |____________|");
            Console.WriteLine("       ||||");
            Console.WriteLine("       ||||");
        }

        public void DisplayInfo()
        {
            Draw();
            Console.WriteLine($"Ракета: {Name}");
            Console.WriteLine($"Производитель: {Company}");
            Console.WriteLine($"Полезная нагрузка: {PayloadCapacity} тонн");
            MakeSound();
            Move();
        }
    }

    public class ProtonM : IMakeSound, IMove
    {
        public string Name { get; set; }
        public string Company { get; set; } = "Роскосмос";

        public ProtonM(string name)
        {
            Name = name;
        }

        public void MakeSound()
        {
            Console.WriteLine($"{Name} издаёт звук: МОЩНЫЙ ГУЛ РД-276!!!");
        }

        public void Move()
        {
            Console.WriteLine($"{Name} летит: классическая тяжёлая ракета на гиперголе");
        }

        public void Draw()
        {
            Console.WriteLine("       /\\");
            Console.WriteLine("      /  \\");
            Console.WriteLine("     /    \\");
            Console.WriteLine("    /  ПР  \\");
            Console.WriteLine("   /  О Т О  \\");
            Console.WriteLine("  /  Н   М    \\");
            Console.WriteLine(" /______________\\");
            Console.WriteLine("     |████|");
            Console.WriteLine("     |████|");
        }

        public void DisplayInfo()
        {
            Draw();
            Console.WriteLine($"Ракета: {Name}");
            Console.WriteLine($"Производитель: {Company}");
            MakeSound();
            Move();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Falcon9 falcon = new Falcon9("Falcon 9");
            Starship starship = new Starship("Starship");
            ProtonM proton = new ProtonM("Протон-М");

            Console.WriteLine("=== ЗАПУСК РАКЕТ ===\n");

            falcon.DisplayInfo();
            Console.WriteLine();

            starship.DisplayInfo();
            Console.WriteLine();

            proton.DisplayInfo();

            Console.WriteLine("\n=== ПОЛИМОРФИЗМ ===\n");

            IMakeSound[] rockets = { falcon, starship, proton };

            foreach (IMakeSound rocket in rockets)
            {
                rocket.MakeSound();
            }

            Console.WriteLine("\nВсе ракеты успешно «запущены» в полиморфном режиме!");

            Console.ReadKey();
        }
    }
}