summaryrefslogtreecommitdiff
path: root/src/Q6/WeekDay.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Q6/WeekDay.java')
-rw-r--r--src/Q6/WeekDay.java32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/Q6/WeekDay.java b/src/Q6/WeekDay.java
index 4447933..b2aa85e 100644
--- a/src/Q6/WeekDay.java
+++ b/src/Q6/WeekDay.java
@@ -23,8 +23,9 @@ public class WeekDay {
public static final int THURSDAY = 4;
public static final int FRIDAY = 5;
public static final int SATURDAY = 6;
- private static String[] DAYS =
+ private static final String[] DAYS =
new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
+ private static final int[] MONTHS = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
public String getWeekDay(int day, int month, int year) {
return DAYS[daysSinceEpoch(day, month, year) % 7];
@@ -49,34 +50,7 @@ public class WeekDay {
}
private int daysInMonth(int month) {
- switch (month) {
- case 1:
- return 31;
- case 2:
- return 28;
- case 3:
- return 31;
- case 4:
- return 30;
- case 5:
- return 31;
- case 6:
- return 30;
- case 7:
- return 31;
- case 8:
- return 31;
- case 9:
- return 30;
- case 10:
- return 31;
- case 11:
- return 30;
- case 12:
- return 31;
- default:
- return 0;
- }
+ return MONTHS[month - 1];
}
public static void main(String[] args) {