Как здесь сделать сортировку? - C#
Формулировка задачи:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Speed { class Speed { private Speed(double kmPerHour) { KilometersPerHour = kmPerHour; } public static Speed FromMetersPerSecond(double metersPerSecond) { return new Speed(metersPerSecond * 3.6); } public static Speed FromKilometersPerHour(double kmPerHour) { return new Speed(kmPerHour); } public static Speed FromMilesPerHour(double milesPerHour) { return new Speed(milesPerHour * 1.609); } public Speed AddMiles(double milesPerHour) { return new Speed(KilometersPerHour + milesPerHour * 1.609); } public Speed SubstractMiles(double milesPerHour) { return new Speed(KilometersPerHour - milesPerHour * 1.609); } public static Speed operator +(Speed speed1, Speed speed2) { return new Speed(speed1.KilometersPerHour + speed2.KilometersPerHour); } public static Speed operator -(Speed speed1, Speed speed2) { return new Speed(speed1.KilometersPerHour - speed2.KilometersPerHour); } public static bool operator > (Speed speed1 , Speed speed2) { return speed1.KilometersPerHour * speed2.MilesPerHour > speed1.MetersPerSecond * speed2.KilometersPerHour; } public static bool operator < (Speed speed1, Speed speed2) { return speed1.MetersPerSecond * speed2.KilometersPerHour < speed1.KilometersPerHour * speed2.MilesPerHour; } public double KilometersPerHour { get { return _kmPerHour; } private set { _kmPerHour = value; } } public double MetersPerSecond { get { return _kmPerHour; } private set { _kmPerHour = value * 3.6; } } public double MilesPerHour { get { return _kmPerHour; } private set { _kmPerHour = value * 1.609; } } private double _kmPerHour; } class Program { static void Main(string[] args) { Console.Write("Введите скорость в метрах в секунду "); Speed speed1 = Speed.FromMetersPerSecond(Convert.ToDouble(Console.ReadLine())); Console.WriteLine("speed1 = " + speed1.KilometersPerHour); Console.Write("Введите скорость в километрах в час "); Speed speed2 = Speed.FromKilometersPerHour(Convert.ToDouble(Console.ReadLine())); Console.WriteLine("speed2 = " + speed2.KilometersPerHour); Console.Write("Введите скорость в милях в час "); Speed speed3 = Speed.FromMilesPerHour(Convert.ToDouble(Console.ReadLine())); Console.WriteLine("speed3 = " + speed3.KilometersPerHour); Speed speed4 = speed1.AddMiles(1); Console.WriteLine("speed4 = " + speed4.KilometersPerHour); Speed speed5 = speed1.SubstractMiles(1.33); Console.WriteLine("speed5 = " + speed5.KilometersPerHour); Console.ReadKey(); } } }
Решение задачи: «Как здесь сделать сортировку?»
textual
Листинг программы
ваш код
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д