Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.8 kB
0
Indexable
Never
using TransportDevice = Transport.Device; // Псевдонимы
using ElectronicDevice = Electronics.Phones.Device;


internal class Program
{
	private static void Main(string[] args)
	{
		TransportDevice[] transportDevices = new TransportDevice[]
		{
			new TransportDevice("Toyota", "Corola", 0001 ),
			new TransportDevice("Ford", "Mustang", 0002 ),
			new TransportDevice("Lada", "Kalina", 0003 ),
		};

		ElectronicDevice[] electronicDevices = new ElectronicDevice[]
		{
			new ElectronicDevice("Tefal", "Teapot", 0001,new DateTime(2024,3,12) ),
			new ElectronicDevice("LG", "TV", 0002, new DateTime(2017,4,13) ),
			new ElectronicDevice("Samsung", "Galaxy", 0003, new DateTime(2010,5,14) ),

		};

		Console.WriteLine(electronicDevices[0].IsNew);
		Console.WriteLine(electronicDevices[1].IsNew);
		Console.WriteLine(electronicDevices[2].IsNew);

	}

}

namespace Electronics.Phones
{
	public class Device // 4
	{
		// Fields (Поля)
		public string Brand;
		public string Model;
		public long SerialNumber;
		public DateTime ReleaseDate;

		// Properties (Свойства)
		public bool IsNew => ReleaseDate.Year >= DateTime.Now.Year;

		// Constructor (Конструктор)
		public Device(string brand, string model, long serialnumber, DateTime releaseDate)
		{
			Brand = brand;
			Model = model;
			SerialNumber = serialnumber;
			ReleaseDate = releaseDate;
		}

		// Methods (Методы)
		public void PrintBrand()
		{
			Console.WriteLine(Brand);
		}
	}
}

namespace Transport
{
	public class Device
	{
		public string Brand;
		public string Model;
		public long SerialNumber;

		public Device(string brand, string model, long serialnumber)
		{
			Brand = brand;
			Model = model;
			SerialNumber = serialnumber;
		}
	}
}
Leave a Comment