-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDate.java
70 lines (61 loc) · 1.44 KB
/
Date.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.io.*;
import java.util.*;
//Date.java
//Date class for various uses
public class Date implements Serializable {
//Instance Variables
private int month;
private int day;
private int year;
//end Instance Variables
//Class Methods
//Null Constructor
public Date() {
this.month = 1;
this.day = 1;
this.year = 1;
} //end Null Constructor
//Constructor
public Date(int iMonth, int iDay, int iYear) { //i means initial
this.month = iMonth;
this.day = iDay;
this.year = iYear;
} //end Constructor
public void setMonth(int newMonth) {
this.month = newMonth;
} //end setMonth
public int getMonth() {
return this.month;
} //end getMonth
public void setDay(int newDay) {
this.day = newDay;
} //end setDay
public int getDay() {
return this.day;
} //end getDay
public void setYear(int newYear) {
this.year = newYear;
} //end setYear
public int getYear() {
return this.year;
} //end getYear
//end Class Methods
/*
//class test
public static int main(String[] args) {
Date birthDate = new Date(11, 9, 1991);
System.out.print("Before: ");
birthDate.getMonth();
birthDate.getDay();
birthDate.getYear();
birthDate.setMonth(3);
birthDate.setDay(5);
birthDate.setYear(1986);
System.out.print("After: ");
birthDate.getMonth();
birthDate.getDay();
birthDate.getYear();
return(0);
} //end Main
*/
} //end Date