using System;
namespace Ulamek
{
public class Program
{
private static void Main()
{
Ulamek ulamek = new Ulamek(1, 5);
Ulamek ulamek1 = new Ulamek(ulamek);
Console.WriteLine(ulamek);
}
}
public class Ulamek : IComparable<Ulamek>, IEquatable<Ulamek>
{
private double num = 1;
private double den = 2;
public Ulamek()
{
}
public Ulamek(double num, double den)
{
if (den == 0)
{
Console.WriteLine("Bład");
}
this.num = num;
this.den = den;
}
public Ulamek(Ulamek other)
{
if (other.den == 0)
{
Console.WriteLine("Bład");
}
this.num = other.num;
this.den = other.den;
}
public static Ulamek operator +(Ulamek first) => first;
public static Ulamek operator -(Ulamek first) => new Ulamek(first.num, first.den);
public static Ulamek operator +(Ulamek first, Ulamek second) => new Ulamek(first.num * second.num, first.den * second.den);
public static Ulamek operator -(Ulamek first, Ulamek second) => first + (-second);
public static Ulamek operator *(Ulamek first, Ulamek second) => new Ulamek(first.num * second.den + second.num * first.den, first.den * second.den);
public static Ulamek operator /(Ulamek first, Ulamek second)
{
if (second.num == 0)
{
Console.WriteLine("bład");
}
return new Ulamek(first.num * second.den, first.den * second.num);
}
public override string ToString() => $"{num}/{den}";
public int CompareTo(Ulamek other)
{
double a = (double)this.num / this.den;
double b = (double)other.num / other.den;
if (a < b)
{
return 1;
}
if (a > b)
{
return -1;
}
return 0;
}
public bool Equals(Ulamek other)
{
return this.num / this.den == other.num / other.den;
}
public double Value
{
get { return (double)this.num / this.den; }
}
public double Ceiliing()
{
double a = (double)this.num / this.den;
return Math.Ceiling(a);
}
public double floor()
{
double a = (double)this.num / this.den;
return Math.Floor(a);
}
}
}
Pytanie: czy jest jakiś artykul w microsft docs o dokumantacji ponieważ dostałem zadanie Dokumentacja dla klasy ulamek i nawet nie wiem co zrobić