diff --git a/200204/ksundong/Solution.java b/200204/ksundong/Solution.java new file mode 100644 index 0000000..8bf6345 --- /dev/null +++ b/200204/ksundong/Solution.java @@ -0,0 +1,20 @@ +/* + * 프로그래머스 2016년 - https://programmers.co.kr/learn/courses/30/lessons/12901 + * - Test Case를 하나 만들었다. + * - 너무 쉬웠다. 역시 CodeSquad Java Playground! + * - https://www.inflearn.com/course/java-codesquad/dashboard + */ +public class Solution { + public String solution(int a, int b) { + String[] dayOfWeek = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; + int dateCount = 5; + int[] monthDayArray = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + for (int i = 0; i < a - 1; i++) { + dateCount += monthDayArray[i]; + } + dateCount += b - 1; + + return dayOfWeek[dateCount % 7]; + } +} diff --git a/200204/ksundong/SolutionTest.java b/200204/ksundong/SolutionTest.java new file mode 100644 index 0000000..b929549 --- /dev/null +++ b/200204/ksundong/SolutionTest.java @@ -0,0 +1,31 @@ +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class SolutionTest { + Solution solution; + + @BeforeEach + void setUp() { + solution = new Solution(); + } + + @Test + void testSolution1() { + int month = 5; + int date = 24; + String expected = "TUE"; + String actual = solution.solution(month, date); + assertEquals(expected, actual, "원하는 요일명과 일치하지 않습니다."); + } + + @Test + void testSolution2() { + int month = 1; + int date = 1; + String expected = "FRI"; + String actual = solution.solution(month, date); + assertEquals(expected, actual, "원하는 요일명과 일치하지 않습니다."); + } +}