Rotspawn
Мудрец
(12332)
4 дня назад
using System;
using System.Collections.Generic;
namespace MilitarySimulation
{
public class Vehicle
{
public string Name { get; set; }
public int Speed { get; set; }
public int Armor { get; set; }
public Vehicle(string name, int speed, int armor)
{
Name = name;
Speed = speed;
Armor = armor;
}
public virtual void DisplayInfo()
{
Console.WriteLine($"Vehicle: {Name}, Speed: {Speed} km/h, Armor: {Armor} mm");
}
}
public class Helicopter : Vehicle
{
public int RotorDiameter { get; set; }
public Helicopter(string name, int speed, int armor, int rotorDiameter)
: base(name, speed, armor)
{
RotorDiameter = rotorDiameter;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Rotor Diameter: {RotorDiameter} m");
}
}
public class Tank : Vehicle
{
public int CannonCaliber { get; set; }
public Tank(string name, int speed, int armor, int cannonCaliber)
: base(name, speed, armor)
{
CannonCaliber = cannonCaliber;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Cannon Caliber: {CannonCaliber} mm");
}
}
public class Airplane : Vehicle
{
public int WingSpan { get; set; }
public Airplane(string name, int speed, int armor, int wingSpan)
: base(name, speed, armor)
{
WingSpan = wingSpan;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Wing Span: {WingSpan} m");
}
}
public class Ship : Vehicle
{
public int Displacement { get; set; }
public Ship(string name, int speed, int armor, int displacement)
: base(name, speed, armor)
{
Displacement = displacement;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Displacement: {Displacement} tons");
}
}
class Program
{
static void Main(string[] args)
{
List<Vehicle> vehicles = new List<Vehicle>
{
new Helicopter("Ka-52", 300, 20, 14),
new Tank("T-80", 72, 120, 120),
new Airplane("Su-27", 2500, 30, 14),
new Ship("Admiral Kuznetsov", 29, 200, 55000)
};
foreach (var vehicle in vehicles)
{
vehicle.DisplayInfo();
Console.WriteLine();
}
}
}
}
using System;
using System.Collections.Generic;
namespace MilitarySimulation
{
public class Vehicle
{
public string Name { get; set; }
public int Speed { get; set; }
public int Armor { get; set; }
public Vehicle(string name, int speed, int armor)
{
Name = name;
Speed = speed;
Armor = armor;
}
public virtual void DisplayInfo()
{
Console.WriteLine($"Vehicle: {Name}, Speed: {Speed} km/h, Armor: {Armor} mm");
}
}
public class Helicopter : Vehicle
{
public int RotorDiameter { get; set; }
public Helicopter(string name, int speed, int armor, int rotorDiameter)
: base(name, speed, armor)
{
RotorDiameter = rotorDiameter;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Rotor Diameter: {RotorDiameter} m");
}
}
public class Tank : Vehicle
{
public int CannonCaliber { get; set; }
public Tank(string name, int speed, int armor, int cannonCaliber)
: base(name, speed, armor)
{
CannonCaliber = cannonCaliber;
}
public override void DisplayInfo()
{
base.DisplayInfo();
Console.WriteLine($"Cannon Caliber: {CannonCaliber} mm");
}
}
class Program
{
static void Main(string[] args)
{
List<Vehicle> vehicles = new List<Vehicle>
{
new Helicopter("Ka-52", 300, 20, 14),
new Tank("T-80", 72, 120, 120)
};
foreach (var vehicle in vehicles)
{
vehicle.DisplayInfo();
Console.WriteLine();
}
}
}
}