-
Notifications
You must be signed in to change notification settings - Fork 248
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λ¨κ³ - μκ°μ μ²(λλ©μΈ λͺ¨λΈ) #627
base: mingulee-devel
Are you sure you want to change the base?
Conversation
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.
μλ νμΈμ λ―Όμ λ π
λͺκ°μ§ μ½λ©νΈ λ¨κ²¨λμλλ° νμΈλΆνλλ €μ :)
κΆκΈνκ±°λ κ³ λ―Όμ΄ λλ λΆλΆμ΄ μμΌμλ€λ©΄ μΈμ λ pr μ½λ©νΈ λλ dmμΌλ‘ μμ² λΆνλ립λλ€.
κ°μ¬ν©λλ€ πββοΈ
|
||
import nextstep.payments.domain.Payment; | ||
|
||
public class FreeSession implements SessionStrategy { |
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.
Session
μ΄λΌλ λλ©μΈμ΄ μ΄λ―Έ μκ³ νμ¬ κ΅¬ν체λ Sessionμ λ°λ₯Έ κ²°μ μ λ΅μ΄κΈ° λλ¬Έμ λ€μ΄λ°μ΄ FreeSessionEnrollStrategy
μ κ°μ΄ μ‘°κΈ λ λͺ
ννλ©΄ μ’μ κ² κ°μμ :)
public void enroll(Payment payment){ //todo | ||
if(canEnroll(payment)){ | ||
payments.add(payment); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canEnroll(Payment payment) { | ||
return !isFull() && payment.isTuitionPaid(tuitionFee); | ||
} |
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.
κ΅¬μ‘°κ° μ΄μν΄λ³΄μ΄λ μ΄μ λ PaidSessionEnrollStrategy
λ₯Ό μ΄λ»κ² νμ©ν κ±΄μ§ λͺ
ννμ§ μμμμΈ κ² κ°μμ. μ§κΈ μ€κ³ν κ°μ²΄μ μν λ‘보면,
- κ°μκ° κ²°μ κ°λ₯ν μν©μΈμ§ νμΈν΄μ€λ€.
- μ΄λ₯Ό μν΄ νμ¬ μκ°μ μ, μ΅λ μκ°μ μ, κ°μλ£λ₯Ό κ°μ§λ€.
- κ²°μ λ₯Ό λ°μ μκ°λ±λ‘νλ€.
λΌκ³ λ°λΌλ³Έλ€λ©΄ SessionEnrollStrategy
λ "μκ° λ±λ‘"μ΄λΌλ λͺ
μ λ§ λμν΄μ£Όλ©΄λκ³ , canEnrollμ΄ λμ§ μλλ€λ©΄ μμΈλ₯Ό ν°νΈλ¦¬λ λ±κ³Ό κ°μ νμλ‘ μκ°ν΄λ³Ό μ μμ κ² κ°μμ.
public interface SessionEnrollStrategy {
void enroll(Payment payment);
}
κ° λμ΄μΌνκ³ ,
public class PaidSessionEnrollStrategy {
// ..
public void enroll(Payment payment) {
// canEnrollμ΄ μλ κ²½μ° μμΈ
// countλ₯Ό μ¬λ¦¬κ³ κ²°μ μ 보 μ μ₯
μ΄ λ μ μκ² μ£ . λ€λ§ ν΄λΉ ν΄λμ€λ μ λ΅μΌλ‘ λΆλ¦¬κ³ μκΈ° λλ¬Έμ νΌλμ μ€ μ μλλ°μ. "μ λ΅"μ΄λΌλ κ²μ μ΄λ€ νμλ₯Ό μ΄λ»κ² μ€ννλλκ° μ£Όμ κ΄μ¬μ¬μ΄μ§ μνλ₯Ό λ€κ³ κ΄λ¦¬νλ©΄μ μ λ΅μ μΆκ΅¬νλ건 μ λ΅μ체μ μ± μμ νμ₯μμΌλ²λ¦΄ μ μμ΄μ. μΆμνλ₯Ό ν΅ν μ κ·Όμ λ§μ§λ§ μ λ΅μ΄λλ κ³ λ―Όν΄λ³΄μλ©΄ μ’μ κ² κ°λ€μ :)
public class Sessions { | ||
private List<Session> values; | ||
} |
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.
κ°μΈμ μΌλ‘ λ¨μν λνλ§νλ ν΄λμ€λ μΌκΈμ»¬λμ μΌλ‘ λ¬Άμ νμλ μλ€κ³ μκ°ν©λλ€. νΉμ λλ©μΈ μ± μ μμ΄ λ¦¬μ€νΈμ΄κΈ° λλ¬Έμ μΌκΈμ»¬λμ μΌλ‘ λλ€λ κ²μ κ³Όν λνμ΄ λ μ μμ΄μ.
public ImageDimensions(int width, int height) { | ||
this.width = width; | ||
this.height = height; | ||
} | ||
|
||
public boolean validDimensions() { |
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.
μμ±μμμ validationμ νμ§ μμΌμλ μ΄μ κ° μμκΉμ? κ°μ²΄μ μμ±μ κ°μ²΄κ° λ΄λΉνλ κ²μ΄ κ°μ²΄ μμ±μ μμ μ±μ 보μ₯ν΄μ :)
BMP; | ||
|
||
public static boolean validExtension(ImageExtension extension) { | ||
if (!Arrays.asList(GIF, JPG, JPEG, PNG, SVG).contains(extension)) { |
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.
νΉμ νμ₯μλ§ κ΄λ¦¬νκ³ μΆλ€λ©΄ μμλ‘ λΉΌλ©΄ μ’μ κ² κ°λ€μ :)
package nextstep.courses.domain.session.coverImage; | ||
|
||
public class ImageSize { | ||
private int size; |
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.
λΆλ³μΌ μ μλ νλλ€μ λͺ¨λ λΆλ³μΌλ‘ μμ ν΄μ£Όμλ©΄ μ’μ κ² κ°μμ :)
|
||
import java.time.LocalDate; | ||
|
||
public class Session { |
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.
SessionService
λ₯Ό ν΅ν΄ enroll λ‘μ§μ ꡬννλκ²κΉμ§κ° λ―Έμ
μ μꡬμ¬νμ΄μμ :)
private SessionStrategy sessionStrategy; | ||
|
||
public Session(SessionCoverImage sessionCoverImage, SessionStatus sessionStatus, SessionStrategy sessionStrategy) { | ||
this(null, null, sessionCoverImage, sessionStatus, sessionStrategy); |
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.
λλ€ nullμΈ μΌμ΄μ€λ₯Ό μμ±μμμ μ§μνλ μ΄μ κ° μμκΉμ?
private FreeSession freeSession; | ||
|
||
@Test | ||
void μκ°μ μ²_κ°λ₯μ¬λΆ_νμΈ() { | ||
freeSession = new FreeSession(); |
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.
νλλ€μ λΆλ³νκ² κ°μ Έκ°μ£Όμλ©΄ μ’μ κ² κ°μμ :) κ°λ³μ μΈ νλλ κ°λ³μ μΌ μ μλ€λΌλ 컨ν μ€νΈλ₯Ό κ³μ μκ³ μ½λλ₯Ό μ½κ² λ§λ€κΈ° λλ¬Έμ κ°λ₯νλ©΄ μ§μν΄μ£Όμλ κ²μ΄ μ’μ΅λλ€.
@Test | ||
void μκ°μ μ²_κ°λ₯μ¬λΆ_νμΈ__κ°μ_μκ°λ£_νμΈ() { | ||
paidSession = new PaidSession(3, 2, 20000); | ||
assertTrue(paidSession.canEnroll(new Payment(20000L))); | ||
paidSession = new PaidSession(3, 2, 20000); | ||
assertFalse(paidSession.canEnroll(new Payment(15000L))); | ||
} | ||
|
||
@Test | ||
void μκ°μ μ²_κ°λ₯μ¬λΆ_νμΈ__μΈμμ΄κ³Ό_νμΈ() { | ||
|
||
paidSession = new PaidSession(3, 2, 20000); | ||
assertTrue(paidSession.canEnroll(new Payment(20000L))); | ||
paidSession = new PaidSession(2, 2, 20000); | ||
assertFalse(paidSession.canEnroll(new Payment(20000L))); | ||
} |
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.
μ λ°μ μΌλ‘ ν μ€νΈμμ μ΄λ€κ²μ ν μ€νΈνκ³ μνλμ§κ° λͺ ννμ§ μμ κ² κ°μμ. ν μ€νΈλΉ κ²μ¦νκ³ μνλ λμμ λͺ ννμ¬μΌνκ³ , μ΄ κΈ°μ€μ΄ μ΄λ ΅λ€κ³ λλΌμ λ€λ©΄ assertionμ΄ νλμ¬μΌλλ€κ³ μκ°ν΄λ³΄μλ©΄ νΈν κ² κ°μμ.
μλ₯Όλ€λ©΄ κ°μ μκ°λ£νμΈμμ κ²μ¦νκ³ μνλ κ²μ canEnrollμ΄ trueμ΄λ€μΈλ° falseμΈκ±Έ ν μ€νΈν νμκ° μμκΉμ? λ μΈμμ΄κ³Ό νμΈμΈλ° canEnrollμ΄ trueμ΄λ€μΈκ±Έ ν μ€νΈν νμκ° μμκΉμ?
μλ νμΈμ!
μ§λλ²μ νΌλλ°± μ£Όμ ¨λ λ΄μ©κ³Ό ν¨κ» 2λ¨κ³ PR λ립λλ€
μ§μλμ΄ λ§μν΄μ£Όμ λλ‘ μ¬λ€λ¦¬ κ²μμ΄ λλκ³ PRλλ¦΄κΉ νλ€κ° 리뷰 κΈ°λ€λ¦¬λ λμ μ¬λ €λ΄ λλ€!
μꡬμ¬νμ μ νλλ‘ νλ€κ³ νλλ° μ κ° κ°μ²΄λ₯Ό μ λλκ±΄μ§ λͺ¨λ₯΄κ² μ΅λλ€
μ€μ€λ‘ ν΄λ³΄κ³ μΆμ΄μ μ΅λν λ€λ₯Έ λΆλ€μ μ½λλ₯Ό νμΈνμ§ μκ³ νλλ°
μ§μ μ΄ μμ΄μ PR λ립λλ€!
νΉμ 보μκ³ ννΈλ₯Ό μ£Όμ€ μ μμκΉμ?!
μ½λμμ todoλ₯Ό λ¬μλμλλ°μ
SessionStrategyλ₯Ό μμλ°λ FreeSessionμ΄λ PaidSession λλμ΄μ PaidSessionμ canEnrollμ΄ trueμΌ λ paymentλ₯Ό λν΄μ£Όλ €κ³ νλλ° λκ° μ΄ λΆλΆμ΄ μ΄μνκ² λκ»΄μ§λλ€... π’
μ€λλ μ λΆν λ립λλ€ π
1λ¨κ³ νΌλλ°± λ°μ