Skip to content

Commit

Permalink
Merge pull request #7 from creaton60/feature/#5
Browse files Browse the repository at this point in the history
[WIP] 온라인 영화 예매 시스템 코드 구현하기
  • Loading branch information
creaton60 authored Jan 12, 2020
2 parents 018de2f + b3f9d1a commit 4cbf817
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/study/book/object/movie/Customer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie;

public class Customer {
}
47 changes: 47 additions & 0 deletions src/main/java/study/book/object/movie/Money.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package study.book.object.movie;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;

@Getter @Setter
@ToString
public class Money {
public static final Money ZERO = Money.wons(0);

private final BigDecimal amount;

public static Money wons(long amount) {
return new Money(BigDecimal.valueOf(amount));
}

public static Money wons(double amount) {
return new Money(BigDecimal.valueOf(amount));
}

Money(BigDecimal amount) {
this.amount = amount;
}

public Money plus(Money amount) {
return new Money(this.amount.subtract(amount.amount));
}

public Money times(double percent) {
return new Money(this.amount.multiply(BigDecimal.valueOf(percent)));
}

public Money minus(Money amount) {
return new Money(this.amount.add(amount.amount));
}

public boolean isLessThan(Money other) {
return amount.compareTo(other.amount) < 0;
}

public boolean isGreaterThanOrEqual(Money other) {
return amount.compareTo(other.amount) >= 0;
}
}
17 changes: 17 additions & 0 deletions src/main/java/study/book/object/movie/Movie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package study.book.object.movie;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;

@Getter @Setter
@ToString
public class Movie {
private Money fee;

public Money calculateMovieFee(Screening screening) {
return fee.minus(new Money(BigDecimal.ZERO));
}
}
19 changes: 19 additions & 0 deletions src/main/java/study/book/object/movie/Reservation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package study.book.object.movie;

import lombok.ToString;

@ToString
public class Reservation {
private Customer customer;
private Screening screening;
private Money fee;
private int audienceCount;

public Reservation(Customer customer, Screening screening, Money fee, int audienceCount) {
this.customer = customer;
this.screening = screening;
this.fee = fee;
this.audienceCount = audienceCount;
}

}
35 changes: 35 additions & 0 deletions src/main/java/study/book/object/movie/Screening.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package study.book.object.movie;

import java.time.LocalDateTime;

public class Screening {
private Movie movie;
private int sequece;
private LocalDateTime whenScreened;

public Screening(Movie movie, int sequence, LocalDateTime whenScreened) {
this.movie = movie;
this.sequece = sequence;
this.whenScreened = whenScreened;
}

public Reservation reserve(Customer customer, int audienceCount) {
return new Reservation(customer, this, calculateFee(audienceCount), audienceCount);
}

public LocalDateTime getStartTime() {
return whenScreened;
}

public boolean isSequence(int sequence) {
return this.sequece == sequece;
}

public Money getMovieFee() {
return movie.getFee();
}

private Money calculateFee(int audienceCount) {
return movie.calculateMovieFee(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie.condition;

public class DiscountCondition {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie.condition;

public class PeriodCondition {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie.condition;

public class SequenceCondition {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie.policy;

public class AmountDiscountPolicy {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie.policy;

public class DiscountPolicy {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package study.book.object.movie.policy;

public class PercentDiscountPolicy {
}

0 comments on commit 4cbf817

Please sign in to comment.