Advertisement
Mira___

(кл)проверено практикум 10_10

Feb 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace MyProgram
  8. {
  9. class ClassDate
  10. {
  11. DateTime date;
  12. // static DateTime date1;
  13. //static ClassDate() //статический конструктор
  14. //{
  15. // date1 = DateTime.Parse(Console.ReadLine());
  16. // //Console.WriteLine("Заданная дата - {0}", date1);
  17. //}
  18. public ClassDate()
  19. {
  20. date = new DateTime(2010, 1, 1);
  21.  
  22. //Console.WriteLine("Определенная дата - {0}", date);
  23. }
  24.  
  25. public ClassDate(DateTime date)
  26. {
  27.  
  28. this.date = date;
  29. // Console.WriteLine("Заданная дата №2 - {0}", date);
  30. }
  31. public DateTime PreviousDay()
  32. {
  33. return date.Subtract(TimeSpan.FromDays(1));
  34.  
  35. }
  36.  
  37. public DateTime NextDay()
  38. {
  39. return date.Add(TimeSpan.FromDays(1));
  40. }
  41.  
  42. public int DaysLeft()
  43. {
  44. return DateTime.DaysInMonth(date.Year, date.Month) - date.Day;
  45. }
  46.  
  47. public DateTime Date
  48. {
  49. get { return date; }
  50. set { date = value; }
  51. }
  52. public bool IsLeap
  53. {
  54. get { return DateTime.IsLeapYear(date.Year); }
  55. }
  56. public DateTime this[int days]
  57. {
  58.  
  59. get { return date.AddDays(days); }
  60. }
  61. public static bool operator !(ClassDate a)
  62. {
  63. return DateTime.DaysInMonth(a.Date.Year, a.Date.Month) != a.Date.Day;
  64. }
  65. public static bool operator true(ClassDate a)
  66. {
  67. return a.date.Month == 1;
  68. }
  69.  
  70. public static bool operator false(ClassDate a)
  71. {
  72. return a.date.Month != 1;
  73. }
  74.  
  75. public static bool operator &(ClassDate a, ClassDate b)
  76. {
  77. return a.Date.Equals(b.Date);
  78. }
  79.  
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement