-
Notifications
You must be signed in to change notification settings - Fork 301
๐ 2๋จ๊ณ - ์๊ฐ์ ์ฒญ(๋๋ฉ์ธ ๋ชจ๋ธ) #691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: nno0obb
Are you sure you want to change the base?
Changes from all commits
9c08e02
b5f0d4d
4d5593c
8ee8f65
214234a
e26e30c
f0e6e28
51577a7
4341b6c
de1e19a
15d7dd2
d03f4aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
org.gradle.jvmargs=-Dfile.encoding=UTF-8 | ||
org.gradle.console=plain | ||
org.gradle.java.home=/opt/homebrew/Cellar/openjdk@11/11.0.26/libexec/openjdk.jdk/Contents/Home | ||
org.gradle.java.home=/opt/homebrew/Cellar/openjdk@11/11.0.26/libexec/openjdk.jdk/Contents/Home | ||
# ๋ต, ์ ์ค์ ์ IDE ์์ Java ์คํ ํ๊ฒฝ์ ์ํด ํ์ํฉ๋๋ค. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ ์คํธ ์ถ๊ฐ๋ ์์ ์ ์์ ๋กญ๊ฒ ์งํํด์ฃผ์ ๋ ๋ฉ๋๋ค ๐ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package nextstep.courses.domain; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import nextstep.users.domain.NsUser; | ||
|
||
public class AttendeeList { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
์๊ตฌ์ฌํญ์๋ ์ด๋ค ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ด๋ผ๋ผ๋ ๊ตฌํ๋ด์ฉ์ ๋ช ์ํ์ง ์๊ธฐ ๋๋ฌธ์ ํ๊ท ๋์ด ์๊ฐํด์ฃผ์๋ ๋ฐฉํฅ๋๋ก ๊ตฌํ์ ํด์ฃผ์๋ฉด ๋์ด์ :) |
||
private final List<NsUser> attendees; | ||
|
||
public AttendeeList() { | ||
this.attendees = new ArrayList<>(); | ||
} | ||
|
||
public void add(NsUser attendee) { | ||
attendees.add(attendee); | ||
} | ||
|
||
public Long size() { | ||
return (long) attendees.size(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||||||||||||||
package nextstep.courses.domain; | ||||||||||||||||||
|
||||||||||||||||||
import java.awt.image.BufferedImage; | ||||||||||||||||||
import java.io.File; | ||||||||||||||||||
import java.io.IOException; | ||||||||||||||||||
import java.net.URI; | ||||||||||||||||||
import java.util.Arrays; | ||||||||||||||||||
|
||||||||||||||||||
import javax.imageio.ImageIO; | ||||||||||||||||||
|
||||||||||||||||||
public class CourseCoverImage { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
์๋ฐํด๋์ค๋ฅผ ํ์ตํ ์ ๋๊น์ง๋ ํ์์๊ณ , ์๊ตฌ๋ ๋ด์ฉ์ ์ด๋ฏธ์ง ๊ด๋ จ๋ ๋๋ฉ์ธ๋ก์ง์ ์ฒ๋ฆฌํ๋ ์ ๋๋ฉด ์ถฉ๋ถํ ๊ฒ ๊ฐ์ต๋๋ค ๐ |
||||||||||||||||||
|
||||||||||||||||||
private static final String[] SUPPORTED_IMAGE_EXTENSIONS = {".gif", ".jpg", ".jpeg", ".png", ".svg"}; | ||||||||||||||||||
private static final int MIN_WIDTH = 300; | ||||||||||||||||||
private static final int MIN_HEIGHT = 200; | ||||||||||||||||||
private static final String DEFAULT_IMAGE_FILE_PATH = "src/test/resources/images/default.jpg"; | ||||||||||||||||||
|
||||||||||||||||||
private String imageFilePath; | ||||||||||||||||||
private File imageFile; | ||||||||||||||||||
|
||||||||||||||||||
private BufferedImage courseCoverImageData; | ||||||||||||||||||
Comment on lines
+18
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
๋ถ๋ณํ ์ ์๊ฒ ๋ค์! |
||||||||||||||||||
|
||||||||||||||||||
public CourseCoverImage(String imageFilePath) { | ||||||||||||||||||
validateImage(imageFilePath); | ||||||||||||||||||
this.imageFilePath = imageFilePath; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
private void validateImage(String imageFilePath) { | ||||||||||||||||||
if (imageFilePath == null) { | ||||||||||||||||||
imageFilePath = DEFAULT_IMAGE_FILE_PATH; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if (Arrays.stream(SUPPORTED_IMAGE_EXTENSIONS).noneMatch(imageFilePath::endsWith)) { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ |
||||||||||||||||||
throw new IllegalArgumentException("์ง์ํ์ง ์๋ ์ด๋ฏธ์ง ํ์์ ๋๋ค. (์ง์ ํ์: gif, jpg, jpeg, png, svg)"); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
try { | ||||||||||||||||||
imageFile = new File(imageFilePath); | ||||||||||||||||||
if (!imageFile.exists()) { | ||||||||||||||||||
throw new IllegalArgumentException("๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง๋ฅผ ์ฝ์ ์ ์์ต๋๋ค."); | ||||||||||||||||||
} | ||||||||||||||||||
} catch (Exception e) { | ||||||||||||||||||
throw new IllegalArgumentException("๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง๋ฅผ ์ฝ์ ์ ์์ต๋๋ค."); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
try { | ||||||||||||||||||
courseCoverImageData = ImageIO.read(imageFile); | ||||||||||||||||||
if (courseCoverImageData == null) { | ||||||||||||||||||
throw new IllegalArgumentException("๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง๋ฅผ ์ฝ์ ์ ์์ต๋๋ค."); | ||||||||||||||||||
} | ||||||||||||||||||
} catch (Exception e) { | ||||||||||||||||||
throw new IllegalArgumentException("๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง๋ฅผ ์ฝ์ ์ ์์ต๋๋ค."); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
if (courseCoverImageData.getWidth() < MIN_WIDTH || courseCoverImageData.getHeight() < MIN_HEIGHT) { | ||||||||||||||||||
throw new IllegalArgumentException("๊ฐ์ ์ปค๋ฒ ์ด๋ฏธ์ง๋ ์ต์ 300x200 ํฝ์ ์ด์์ด์ด์ผ ํฉ๋๋ค."); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
๋ ์ถ๊ฐ๋๋ฉด ์ข๊ฒ ๋ค์ ๐ |
||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package nextstep.courses.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class CourseFree extends Course { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
๋ฌด๋ฃ๊ฐ์๋ ์ต๋ ์๊ฐ ์ธ์ ์ ํ์ด ์๊ธฐ๋ ํ์ง๋ง |
||
|
||
public static final Long MAX_ATTENDEES = Long.MAX_VALUE; | ||
|
||
public CourseFree(String title, Long creatorId, String courseCoverImageFilePath) { | ||
super(title, creatorId, courseCoverImageFilePath, MAX_ATTENDEES); | ||
} | ||
|
||
public CourseFree(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt, String courseCoverImageFilePath) { | ||
super(id, title, creatorId, createdAt, updatedAt, courseCoverImageFilePath, MAX_ATTENDEES, CourseStatus.PREPARING); | ||
} | ||
|
||
public CourseFree(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt, String courseCoverImageFilePath, CourseStatus courseStatus) { | ||
super(id, title, creatorId, createdAt, updatedAt, courseCoverImageFilePath, MAX_ATTENDEES, courseStatus); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package nextstep.courses.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class CoursePaid extends Course { | ||
|
||
public CoursePaid(String title, Long creatorId, String courseCoverImageFilePath, Long maxAttendees) { | ||
super(title, creatorId, courseCoverImageFilePath, maxAttendees); | ||
} | ||
|
||
public CoursePaid(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt, String courseCoverImageFilePath, Long maxAttendees) { | ||
super(id, title, creatorId, createdAt, updatedAt, courseCoverImageFilePath, maxAttendees, CourseStatus.PREPARING); | ||
} | ||
|
||
public CoursePaid(Long id, String title, Long creatorId, LocalDateTime createdAt, LocalDateTime updatedAt, String courseCoverImageFilePath, Long maxAttendees, CourseStatus courseStatus) { | ||
super(id, title, creatorId, createdAt, updatedAt, courseCoverImageFilePath, maxAttendees, courseStatus); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum CourseStatus { | ||
PREPARING, | ||
RECRUITING, | ||
ENDED | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nextstep.courses.domain; | ||
|
||
public class Session { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nextstep.courses.domain; | ||
|
||
public class SessionList { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package nextstep.qna.domain; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class AnswerList implements Iterable<Answer> { | ||
|
||
private final List<Answer> answers; | ||
|
||
public AnswerList() { | ||
this.answers = new ArrayList<>(); | ||
} | ||
|
||
public AnswerList(List<Answer> answers) { | ||
this.answers = answers; | ||
} | ||
|
||
public List<Answer> getAnswers() { | ||
return answers; | ||
} | ||
|
||
public void add(Answer answer) { | ||
answers.add(answer); | ||
} | ||
|
||
@Override | ||
public Iterator<Answer> iterator() { | ||
return answers.iterator(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package nextstep.users.domain; | ||
|
||
import nextstep.qna.UnAuthorizedException; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Objects; | ||
|
||
import nextstep.courses.domain.Course; | ||
import nextstep.courses.domain.CourseFree; | ||
import nextstep.courses.domain.CoursePaid; | ||
import nextstep.courses.domain.CourseStatus; | ||
import nextstep.qna.UnAuthorizedException; | ||
|
||
public class NsUser { | ||
public static final GuestNsUser GUEST_USER = new GuestNsUser(); | ||
|
||
|
@@ -124,6 +128,22 @@ public boolean isGuestUser() { | |
} | ||
} | ||
|
||
public void registerCourse(Course course) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
๋ง์ํด์ฃผ์ ๋ด์ฉ์ ์ดํด๋ชปํ์ด์. ์กฐ๊ธ ๋ ์์ธํ๊ฒ ๋ง์ํด์ฃผ์๋ฉด ํ์ธํด๋ณด๊ฒ ์ต๋๋ค ๐ |
||
if (course.getCourseStatus() == CourseStatus.PREPARING) { | ||
throw new IllegalArgumentException("๊ฐ์๊ฐ ์ค๋น์ค์ ๋๋ค."); | ||
} | ||
Comment on lines
+132
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ด๋ฐ ๋ก์ง๋ ๊ฐ์์ ๋ํ ๊ฒ์ฆ ์ฑ
์ ์์ฒด๋ฅผ |
||
if (course.getAttendees().size() >= course.getMaxAttendees()) { | ||
throw new IllegalArgumentException("๊ฐ์ ์๊ฐ ์ธ์์ด ์ด๊ณผ๋์์ต๋๋ค."); | ||
} | ||
Comment on lines
+135
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
๋๊ฐ ์๊ฐ๋ฑ๋ก์ ๋ํ ๊ฒ์ ๊ฐ์ ธ๊ฐ๋๋์ ๋ํ ๊ฒ์ ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ์์ ๐ "์๊ฐ"์ด๋ผ๋ ๊ฒ์ ๊ฐ์์ ํ์์ด ๋ค์ด๊ฐ๋ ๊ฒ์ด๋ฏ๋ก |
||
if (course instanceof CoursePaid) { | ||
// Payment... | ||
course.getAttendees().add(this); | ||
} | ||
if (course instanceof CourseFree) { | ||
course.getAttendees().add(this); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NsUser{" + | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด๊ฑธ ์ค์ ํ๊ฒ๋๋ฉด gradle์ ์คํํ๋ ๊ณผ์ ์์ ํด๋น path๊ฐ ๋น์ด์๋ ๋ค๋ฅธ ์ฌ๋์ ๊ฒฝ์ฐ์๋ ์คํ์ด ๋ถ๊ฐ๋ฅํ ๊ฒ ๊ฐ์์. ์ค์ ์๋ฒ์์๋ ๋๋ฝ๋๋ฉด ์คํ์ด ๋์ง ์์ ๊ฒ์ด๊ตฌ์.
์ดํ๋ฆฌ์ผ์ด์ ์คํ๊ณผ ๊ด๋ จ๋ gradle์ ์ค์ ํ ๋๋ ๊ฐ๋ฅํ๋ฉด ํน์ path์ ์์กดํ์ง ์๋ ๊ฒ์ด ์ข์ต๋๋ค :)