Skip to content

Commit

Permalink
Merge pull request #37 from GDSC-snowflowerthon/feat/quiz-32
Browse files Browse the repository at this point in the history
[feat] quiz 중복제거 #32
  • Loading branch information
yunji118 authored Jan 12, 2024
2 parents 0f2ca44 + b5a90b6 commit 71f452f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/com/ALGo/ALGo_server/quiz/Service/QuizService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.*;

@Service
@RequiredArgsConstructor
Expand All @@ -22,14 +20,14 @@ public class QuizService {
public QuizResponseDto getQuiz(){
Random random = new Random();

List<QuizDto> quizDtoList = new ArrayList<>();
for(int i=0;i<4;i++){
Set<QuizDto> quizDtoList = new HashSet<>();
while (quizDtoList.size() < 4){
Long randomNum = Long.valueOf(random.nextInt(16) + 1);
Quiz q = quizRepository.findById(randomNum).get();
QuizDto quizDto = new QuizDto(q);
quizDtoList.add(quizDto);
}
QuizResponseDto responseDto = new QuizResponseDto(quizDtoList);
QuizResponseDto responseDto = new QuizResponseDto(quizDtoList.stream().toList());

return responseDto;
}
Expand Down

0 comments on commit 71f452f

Please sign in to comment.