-
Notifications
You must be signed in to change notification settings - Fork 247
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
π 2λ¨κ³ - μκ°μ μ²(λλ©μΈ λͺ¨λΈ) #326
base: choomi1217
Are you sure you want to change the base?
Changes from all commits
14b0c5a
797ab27
b2ad421
4ea825a
f60212f
576e809
7bf5620
aeb027f
8a9d570
92c1694
b677380
ef71cd2
89a679b
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package nextstep.courses.domain; | ||
|
||
public class FreeSessionType implements SessionType { | ||
|
||
private static final int ZERO = 0; | ||
|
||
private final int pirce; | ||
|
||
public FreeSessionType() { | ||
this.pirce = ZERO; | ||
} | ||
|
||
public FreeSessionType registered() { | ||
return new FreeSessionType(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum ImageExtension { | ||
GIF, JPG, JPEG, PNG, SVG | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package nextstep.courses.domain; | ||
|
||
import nextstep.payments.domain.Payment; | ||
|
||
public class PaidSessionType implements SessionType { | ||
|
||
private int maximumHeadCount; | ||
private long price; | ||
|
||
public PaidSessionType(int maximumHeadCount, long price) { | ||
this.maximumHeadCount = maximumHeadCount; | ||
this.price = price; | ||
} | ||
|
||
private void canRegistered(long payedPrice, int headCount) { | ||
int nextHeadCount = headCount + 1; | ||
if (maximumHeadCount < nextHeadCount) { | ||
throw new IllegalArgumentException("μΈμμκ° μ΄κ³Όνμ΅λλ€."); | ||
} | ||
if (payedPrice < this.price) { | ||
throw new IllegalArgumentException("μ§λΆνμ κΈμ‘μ΄ λͺ¨μλλλ€."); | ||
} | ||
} | ||
|
||
public PaidSessionType registered(long payedPrice, int headCount) { | ||
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. λ±λ‘ κ°λ₯νμ§ νμΈνλ λΆλΆμ μΆμννλ©΄ μ’μ κ² κ°μμ! μ§κΈμ μΈν°νμ΄μ€μ λ©μλκ° νλλ μλ κ² κ°μμμ..! |
||
canRegistered(payedPrice, headCount); | ||
return new PaidSessionType(headCount + 1, this.price); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package nextstep.courses.domain; | ||
|
||
public class Session { | ||
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. μμ±μλ λ©μλκ° λ€ μκ΅°μ..! 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 Long id; | ||
private SessionPeriod period; | ||
private SessionImage image; | ||
private SessionType type; | ||
private SessionStatus status; | ||
private int price; | ||
private int headCount; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package nextstep.courses.domain; | ||
|
||
public class SessionImage { | ||
|
||
private static final int ONE_MEGA_BYTE = 1_000_000; | ||
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. νμΌ ν¬κΈ°λ λ³΄ν΅ byte λ¨μλ‘, 1024*1024 μλ° μμΌλ‘ ννν΄μ ~ |
||
|
||
private Integer capacity; | ||
private ImageExtension extension; | ||
private SessionImageSize size; | ||
|
||
public SessionImage(int capacity, ImageExtension extension, int width, int height) { | ||
validate(capacity); | ||
this.capacity = capacity; | ||
this.extension = extension; | ||
this.size = new SessionImageSize(width, height); | ||
} | ||
|
||
private void validate(int capacity) { | ||
capacityValidate(capacity); | ||
} | ||
|
||
private void capacityValidate(int capacity) { | ||
if (ONE_MEGA_BYTE < capacity) { | ||
throw new IllegalArgumentException(" μ΄λ―Έμ§ μ©λμ 1MB μ΄νλ§ κ°λ₯ν©λλ€. "); | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package nextstep.courses.domain; | ||
|
||
public class SessionImageSize { | ||
|
||
private static final int WIDTH_RATIO = 3; | ||
private static final int HEIGHT_RATIO = 2; | ||
private static final int WIDTH_MAXIMUM = 300; | ||
private static final int HEIGHT_MAXIMUM = 200; | ||
|
||
private int width; | ||
private int height; | ||
private String ratio; | ||
|
||
public SessionImageSize(int width, int height) { | ||
validation(width, height); | ||
this.width = width; | ||
this.height = height; | ||
this.ratio = calculateRatio(); | ||
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 void validation(int width, int height) { | ||
widthAndHeightValidate(width, height); | ||
ratioValidate(width, height); | ||
} | ||
|
||
private void ratioValidate(int width, int height) { | ||
if (WIDTH_RATIO != calculaateWidthRatio(width) && HEIGHT_RATIO != calculaateHeightRatio(height)) { | ||
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(" μ΄λ―Έμ§ λΉμ¨μ 3:2λ§ κ°λ₯ν©λλ€."); | ||
} | ||
} | ||
|
||
private void widthAndHeightValidate(int width, int height) { | ||
if (width < WIDTH_MAXIMUM || height < HEIGHT_MAXIMUM) { | ||
throw new IllegalArgumentException(" μ΄λ―Έμ§μ ν¬κΈ°λ μΈλ‘ 300, κ°λ‘ 200 ν½μ μ΄μλ§ κ°λ₯ν©λλ€. "); | ||
} | ||
} | ||
|
||
private String calculateRatio() { | ||
return calculaateWidthRatio(width) + ":" + calculaateHeightRatio(height); | ||
} | ||
|
||
private int calculaateWidthRatio(int width) { | ||
int divided = width / 100; | ||
if(WIDTH_RATIO != divided){ | ||
divided = divided / WIDTH_RATIO; | ||
} | ||
return divided; | ||
} | ||
|
||
private int calculaateHeightRatio(int height) { | ||
int divided = height / 100; | ||
if(HEIGHT_RATIO != divided){ | ||
divided = divided / HEIGHT_RATIO; | ||
} | ||
return divided; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nextstep.courses.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class SessionPeriod { | ||
|
||
private LocalDateTime startAt; | ||
|
||
private LocalDateTime endAt; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nextstep.courses.domain; | ||
|
||
public enum SessionStatus { | ||
PREPARING, RECRUITING, END | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package nextstep.courses.domain; | ||
|
||
public interface SessionType { | ||
} |
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.
νμ₯μλ enumλ³΄λ€ μ κ·μμΌλ‘ κ²μ¬ν΄λ³΄λκ² μ΄λ¨κΉμ ?