Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions 200204/ksundong/Solution.java
Original file line number Diff line number Diff line change
@@ -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];
}
}
31 changes: 31 additions & 0 deletions 200204/ksundong/SolutionTest.java
Original file line number Diff line number Diff line change
@@ -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, "원하는 요일명과 일치하지 않습니다.");
}
}