From 3e840687259cbe49ab06d306728bf68a05d6d5f9 Mon Sep 17 00:00:00 2001 From: Song-EunJu Date: Fri, 18 Nov 2022 03:08:09 +0900 Subject: [PATCH] =?UTF-8?q?add:=20=EC=A4=91=EB=B3=B5=20=EC=8A=A4=ED=8B=B0?= =?UTF-8?q?=EC=BB=A4=20=EC=A2=85=EB=A5=98=20=EB=82=98=EC=98=A4=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=A0=9C=EA=B1=B0=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/goorm/FileItemReaderJobConfig.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/goorm/FileItemReaderJobConfig.java b/src/main/java/com/example/goorm/FileItemReaderJobConfig.java index a2132da..e21789a 100644 --- a/src/main/java/com/example/goorm/FileItemReaderJobConfig.java +++ b/src/main/java/com/example/goorm/FileItemReaderJobConfig.java @@ -16,6 +16,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + @Slf4j @Configuration @RequiredArgsConstructor @@ -63,9 +67,16 @@ public ItemProcessor csvProcessor() { double y = Double.parseDouble(pos.split(" ")[1]); double z = Double.parseDouble(pos.split(" ")[2]); + ArrayList stickers = new ArrayList(Arrays.asList(1,2,3,4)); + int left = (int)(Math.random()*5); // 0~4 (스티커 안붙이는 경우 고려) - // 왼쪽이 빈 스티커인 경우, 무조건 오른쪽 스티커는 있도록 - int right = (left == 0) ? (int)(Math.random()*4)+1 : (int)(Math.random()*5); + int right; + if(left == 0) // 왼쪽이 빈 스티커인 경우, 무조건 오른쪽 스티커는 있도록 + right = (int)(Math.random()*4)+1; + else { // 왼쪽이 빈 스티커가 아닌 경우, 오른쪽은 걔랑 다른 숫자 + stickers.remove((Integer) left); + right = stickers.get((int)(Math.random()*3)); // 0~2 중에 하나 + } Oreum oreum = Oreum.builder() .name(name)