-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKISSExample.java
More file actions
58 lines (52 loc) · 1.64 KB
/
KISSExample.java
File metadata and controls
58 lines (52 loc) · 1.64 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
package com.upGrad;
public class KISSExample {
public String weekday1(int day) throws InvalidOperationException {
switch (day) {
case 1:
return "Monday";
case 2:
return "Tuesday";
case 3:
return "Wednesday";
case 4:
return "Thursday";
case 5:
return "Friday";
case 6:
return "Saturday";
case 7:
return "Sunday";
default:
throw new InvalidOperationException("day must be in range 1 to 7");
}
}
public String weekday2(int day) throws InvalidOperationException {
if ((day < 1) || (day > 7)) throw new InvalidOperationException("day must be in range 1 to 7");
String[] days = {
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
return days[day - 1];
}
}
class InvalidOperationException extends Exception{
public InvalidOperationException() {
}
public InvalidOperationException(String message) {
super(message);
}
public InvalidOperationException(String message, Throwable cause) {
super(message, cause);
}
public InvalidOperationException(Throwable cause) {
super(cause);
}
public InvalidOperationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}