-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/#9' into develop
[update feature] 트레이드오프 설계 품질
- Loading branch information
Showing
8 changed files
with
148 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
package study.book.object.movie; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@Getter @Setter | ||
@ToString | ||
public class Customer { | ||
private String name; | ||
private String id; | ||
|
||
public Customer(String name, String id) { | ||
this.name = name; | ||
this.id = id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package study.book.object.movie; | ||
|
||
public enum MovieType { | ||
AMOUNT_DISCOUNT, | ||
PERCENT_DISCOUNT, | ||
NONE_DISCOUNT | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/study/book/object/movie/ReservationAgency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package study.book.object.movie; | ||
|
||
public class ReservationAgency { | ||
|
||
public Reservation reserve(Screening screening, Customer customer, int audienceCount) { | ||
Money fee = screening.calculateFee(audienceCount); | ||
|
||
return new Reservation(customer, screening, fee, audienceCount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 32 additions & 3 deletions
35
src/main/java/study/book/object/movie/condition/DiscountCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
package study.book.object.movie.condition; | ||
|
||
import study.book.object.movie.Screening; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
public interface DiscountCondition { | ||
import java.time.DayOfWeek; | ||
import java.time.LocalTime; | ||
|
||
boolean isSatisfiedBy(Screening screening); | ||
@Getter @Setter | ||
@ToString | ||
public class DiscountCondition { | ||
private DiscountConditionType type; | ||
|
||
private int sequence; | ||
|
||
private DayOfWeek dayOfWeek; | ||
private LocalTime startTime; | ||
private LocalTime endTime; | ||
|
||
public boolean isDiscountable(DayOfWeek dayOfWeek, LocalTime time) { | ||
if(type != DiscountConditionType.PERIOD) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
return this.dayOfWeek.equals(dayOfWeek) && | ||
this.startTime.compareTo(time) <= 0 && | ||
this.endTime.compareTo(time) >=0; | ||
} | ||
|
||
public boolean isDiscountable(int sequence) { | ||
if (type != DiscountConditionType.SEQUENCE) { | ||
throw new IllegalArgumentException(); | ||
} | ||
return this.sequence == sequence; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/study/book/object/movie/condition/DiscountConditionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package study.book.object.movie.condition; | ||
|
||
public enum DiscountConditionType { | ||
SEQUENCE, // 순번 조건 | ||
PERIOD //기간 조건 | ||
} |