Files
OAiP-Presnyakov_Ilya-Practi…/Letter.cs
Debug_pro 8d81324fd9 be
2026-03-03 04:00:06 +03:00

29 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace Prac7Meow
{
internal class Letter
{
public int Number { get; }
public string Sender { get; }
public string Recipient { get; }
public double Weight { get; }
public int TermDays { get; }
public Letter(int number, string sender, string recipient, double weight, int termDays)
{
if (number <= 0) throw new ArgumentOutOfRangeException( nameof(number), "Number must be > 0" );
if (string.IsNullOrWhiteSpace(sender)) throw new ArgumentException( "Sender can't be empty", nameof(sender) );
if (string.IsNullOrWhiteSpace(recipient)) throw new ArgumentException( "Recipient can't be empty", nameof(recipient) );
if (weight <= 0) throw new ArgumentOutOfRangeException( nameof(weight), "Weight must be > 0" );
if (termDays <= 0) throw new ArgumentOutOfRangeException( nameof(termDays), "TermDays must be > 0" );
Number = number;
Sender = sender;
Recipient = recipient;
Weight = weight;
TermDays = termDays;
}
public override string ToString() => $"Письмо #{Number}: {Sender} -> {Recipient}, {Weight:F1} г, срок {TermDays} дн.";
}
}