Advertisement
stanevplamen

02.05.01.LeapYear

Jul 30th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. class Year
  4. {
  5.     private int year;
  6.  
  7.     public int LeapYear
  8.     {
  9.         get
  10.         {
  11.             return this.year;
  12.         }
  13.         set
  14.         {
  15.             this.year = value;
  16.         }
  17.     }
  18.  
  19.     public Year()
  20.     {
  21.         this.year = 2010;
  22.     }
  23.  
  24.     static bool IsLeap(int year)
  25.     {
  26.         bool four = year % 4 == 0;
  27.         bool hundred = year % 100 == 0;
  28.         bool fourHundred = year % 400 == 0;
  29.  
  30.         bool first = four ^ hundred;
  31.         bool final = first | fourHundred;
  32.         return final;
  33.     }
  34.  
  35.     static void Main(string[] args)
  36.     {
  37.         Year myYear = new Year();
  38.         myYear.LeapYear = 2000;
  39.  
  40.         bool check = IsLeap(myYear.LeapYear);
  41.         Console.WriteLine("{0} id leap? - {1}", myYear.LeapYear, check);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement