Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- Person User1 = new Person("Ilsaf", "Musin", new DateTime(2003, 05, 27));
- Person User2 = new Person();
- User2.Year = 1999;
- Console.WriteLine("User1: {0}, {1}, {2}",User1.Name, User1.Surname, User1.DayOfBDay);
- Console.WriteLine(User2.ToString());
- Console.WriteLine(User2.ToShortString());
- }
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace lab66oop
- {
- public class Person
- {
- private string name;
- private string surname;
- private DateTime dayofBDay;
- public Person(string name, string surname, DateTime dayofBDay)
- {
- this.name = name;
- this.surname = surname;
- this.dayofBDay = dayofBDay;
- }
- public Person()
- {
- this.name = "NoName";
- this.surname = "NoNamemov";
- this.dayofBDay = new DateTime();
- }
- public string Name
- {
- get { return this.name; }
- set { this.name = value; }
- }
- public string Surname
- {
- get { return this.surname; }
- set { this.surname = value; }
- }
- public DateTime DayOfBDay
- {
- get { return this.dayofBDay; }
- set { this.dayofBDay = value; }
- }
- public int Year
- {
- get { return this.dayofBDay.Year; }
- set => this.dayofBDay = new DateTime(value, this.dayofBDay.Month, this.dayofBDay.Day);
- }
- public override string ToString()
- {
- return $"{this.name} {this.surname} {this.dayofBDay}";
- }
- public virtual string ToShortString()
- {
- return $"{this.name} {this.surname}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement