Skip to content

Commit

Permalink
Update taejung assignment2 #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Aqudi committed Aug 27, 2023
1 parent 0c12a91 commit 32e601f
Show file tree
Hide file tree
Showing 22 changed files with 491 additions and 14 deletions.
11 changes: 11 additions & 0 deletions taejung/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions taejung/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions taejung/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions taejung/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions taejung/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions taejung/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions taejung/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions taejung/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>taejung_</groupId>
<artifactId>assignment2</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
23 changes: 23 additions & 0 deletions taejung/src/main/java/taejung/movie/Audience.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package taejung.movie;

import taejung.money.Money;


public class Audience {

private AudienceType audienceType;
private int audienceCount;

public Audience(AudienceType audienceType, Money fee, int audienceCount) {
this.audienceType = audienceType;
this.audienceCount = audienceCount;
}

public AudienceType getAudienceType() {
return audienceType;
}

public int getAudienceCount() {
return audienceCount;
}
}
18 changes: 18 additions & 0 deletions taejung/src/main/java/taejung/movie/AudienceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package taejung.movie;

public enum AudienceType {
ADULT("성인"),
TEENS("청소년"),
CHILDREN("어린이");

final String name;

AudienceType(String name) {
this.name = name;
}

@Override
public String toString() {
return name;
}
}
4 changes: 3 additions & 1 deletion taejung/src/main/java/taejung/movie/Customer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package taejung.movie;

import java.util.List;

public class Customer {
private String name;
private String id;

public Customer(String name, String id) {
this.id = id;
this.name = name;
Expand Down
28 changes: 28 additions & 0 deletions taejung/src/main/java/taejung/movie/DefaultRefundPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package taejung.movie;

import taejung.money.Money;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public abstract class DefaultRefundPolicy implements RefundPolicy {
private List<RefundCondition> conditions = new ArrayList<>();

public DefaultRefundPolicy(RefundCondition... conditions) {
this.conditions = Arrays.asList(conditions);
}

@Override
public Money calculateRefundAmount(Screening screening) {
for(RefundCondition each : conditions) {
if (each.isRefundable(screening)) {
return getRefundAmount(screening);
}
}

return Money.ZERO;
}

abstract protected Money getRefundAmount(Screening Screening);
}
16 changes: 15 additions & 1 deletion taejung/src/main/java/taejung/movie/Movie.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public class Movie {
private Duration runningTime;
private Money fee;
private DiscountPolicy discountPolicy;
private RefundPolicy refundPolicy;

public Movie(String title, Duration runningTime, Money fee, DiscountPolicy discountPolicy) {
public Movie(String title, Duration runningTime, Money fee, DiscountPolicy discountPolicy, RefundPolicy refundPolicy) {
this.title = title;
this.runningTime = runningTime;
this.fee = fee;
this.discountPolicy = discountPolicy;
this.refundPolicy = refundPolicy;
}

public Money getFee() {
Expand All @@ -24,5 +26,17 @@ public Money getFee() {
public Money calculateMovieFee(Screening screening) {
return fee.minus(discountPolicy.calculateDiscountAmount(screening));
}

public Money calculateRefundAmount(Screening screening) {
return refundPolicy.calculateRefundAmount(screening);
}

public Duration getRunningTime() {
return this.runningTime;
}

public String getTitle() {
return title;
}
}

5 changes: 5 additions & 0 deletions taejung/src/main/java/taejung/movie/RefundCondition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package taejung.movie;

public interface RefundCondition {
boolean isRefundable(Screening screening);
}
7 changes: 7 additions & 0 deletions taejung/src/main/java/taejung/movie/RefundPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package taejung.movie;

import taejung.money.Money;

public interface RefundPolicy {
Money calculateRefundAmount(Screening screening);
}
Loading

0 comments on commit 32e601f

Please sign in to comment.