You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
911 B

6 years ago
  1. // The Date class that represents dates
  2. // Do not make any changes to this file!
  3. // Xiwei Wang
  4. import java.io.*;
  5. public class Date implements Serializable
  6. {
  7. // instance variables
  8. protected int m_year;
  9. protected int m_month;
  10. protected int m_day;
  11. // copy constructor
  12. public Date(Date o)
  13. {
  14. m_year = o.m_year;
  15. m_month = o.m_month;
  16. m_day = o.m_day;
  17. }
  18. // constructor
  19. public Date(int month, int day, int year)
  20. {
  21. m_year = year;
  22. m_month = month;
  23. m_day = day;
  24. }
  25. // observers
  26. public int getYear()
  27. {
  28. return m_year;
  29. }
  30. public int getMonth()
  31. {
  32. return m_month;
  33. }
  34. public int getDay()
  35. {
  36. return m_day;
  37. }
  38. // return this date as a String
  39. public String toString()
  40. {
  41. return (m_month + "/" + m_day + "/" + m_year);
  42. }
  43. }