forked from jerager/CS111Lab11B
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateObject.java
More file actions
136 lines (102 loc) · 2.41 KB
/
Copy pathDateObject.java
File metadata and controls
136 lines (102 loc) · 2.41 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Lab11 Start Names Here Please
public class DateObject {
// 1 o'oclock section
private int day;
private int month;
private int year;
private String calendar;
private static String[] names = {"No Month Zero","January","February","March",
"April","May","June","July","August","September","October",
"November","December"};
public static int monthToInt(String name) {
for (int i=1; i<13; i++) {
if (name.equals(names[i]))
return i;
}
return -1;
}
public void setDay(String m, int d, int y) {
day = d;
year = y;
month = monthToInt(m);
calendar = "Gregorian";
}
public void setDay(String m, int d, int y, String cal) {
}
public void bump() {
day = day + 1;
}
public String printRep() {
return names[month]+"/"+day+"/"+year;
}
// calculate the days in the month Use isLeap
public int daysInMonth() {
return 0;
}
// call one of isLeapGregorian and isLeap Julian
public boolean isLeap() {
return false;
}
// leap year if divisible by 400, or if divisible by 4 and not 100
public boolean isLeapGregorian() {
return false;
}
// leap year if divisible by 4
public boolean isLeapJulian() {
return false;
}
public boolean sameDate(DateObject other) {
if (day == other.day && year == other.year && month == other.month)
return true;
else
return false;
}
// return true if December 31
public boolean isLastDayInYear() {
return false;
}
// return a new Date with the same fields as this one
public DateObject generateCopy() {
DateObject new1 = new DateObject();
return new1;
}
// return a new Date with the same fields as this one's tomorrow
public DateObject generateTomorrow() {
DateObject new1 = new DateObject();
return new1;
}
//return the year
public int getYear() {
return 0;
}
// return the day
public int getDay() {
return 0;
}
// return the month
public String getMonth() {
return null;
}
// finish this - check for the end of a month use daysinmonth
public void makeTomorrow() {
if (isLastDayInYear()) {
day = 1;
month = 1;
year = year+1;
}
else {
bump();
}
}
// move forward n days (use makeTomorrow
public void makeTomorrow(int n){
}
// return true if this is after other
public boolean after(DateObject other) {
return false;
}
// return true if this is before other
public boolean before(DateObject other) {
return false;
}
}