Advertisement
mmayoub

MyDate class

Dec 16th, 2022
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | Software | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace ConsoleApp17
  6. {
  7.     class MyDate
  8.     {
  9.         private int day;
  10.         private int month;
  11.         private int year;
  12.  
  13.         public MyDate(int d, int m, int y)
  14.         {
  15.             day = d;
  16.             month = m;
  17.             year = y;
  18.         }
  19.  
  20.         public int getDay()
  21.         {
  22.             return day;
  23.         }
  24.  
  25.         public int getMonth()
  26.         {
  27.             return month;
  28.         }
  29.  
  30.         public int getYear()
  31.         {
  32.             return year;
  33.         }
  34.  
  35.         public void setDay(int newDay)
  36.         {
  37.             if (newDay >= 1 && newDay <= 31)
  38.             {
  39.                 day = newDay;
  40.             }
  41.  
  42.         }
  43.  
  44.         public void setMonth(int newMonth)
  45.         {
  46.             month = newMonth;
  47.         }
  48.  
  49.         public void setYear(int newYear)
  50.         {
  51.             year = newYear;
  52.         }
  53.  
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement