Skip to content
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

Student #1303

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Student #1303

Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/core/basesyntax/BirthdayDiscountService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package core.basesyntax.strategy.impl;

import core.basesyntax.strategy.DiscountService;

public class BirthdayDiscountService implements DiscountService {
@Override
public double getDiscount() {
return 33;
}
}

10 changes: 10 additions & 0 deletions src/main/java/core/basesyntax/BlackFridayDiscountService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package core.basesyntax.strategy.impl;

import core.basesyntax.strategy.DiscountService;

public class BlackFridayDiscountService implements DiscountService {
@Override
public double getDiscount() {
return 45;
}
}
10 changes: 10 additions & 0 deletions src/main/java/core/basesyntax/DefaultDiscountService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package core.basesyntax.strategy.impl;

import core.basesyntax.strategy.DiscountService;

public class DefaultDiscountService implements DiscountService {
@Override
public double getDiscount() {
return 0;
}
}
5 changes: 5 additions & 0 deletions src/main/java/core/basesyntax/DiscountService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package core.basesyntax.strategy;

public interface DiscountService {
double getDiscount();
}
22 changes: 22 additions & 0 deletions src/main/java/core/basesyntax/DiscountStrategy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package core.basesyntax;

import core.basesyntax.strategy.DiscountService.java;
import core.basesyntax.strategy.impl.BirthdayDiscountService.java;
import core.basesyntax.strategy.impl.BlackFridayDiscountService.java;
import core.basesyntax.strategy.impl.NewYearDiscountService.java;
import core.basesyntax.strategy.impl.DefaultDiscountService.java;

public class DiscountStrategy {
public DiscountService getDiscountServiceBySpecialEvent(String specialEvent) {
switch (specialEvent) {
case "Birthday":
return new BirthdayDiscountService();
case "Black Friday":
return new BlackFridayDiscountService();
case "New Year":
return new NewYearDiscountService();
default:
return new DefaultDiscountService();
}
}
}
8 changes: 0 additions & 8 deletions src/main/java/core/basesyntax/HelloWorld.java

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/core/basesyntax/NewYearDiscountService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package core.basesyntax.strategy.impl;

import core.basesyntax.strategy.DiscountService;

public class NewYearDiscountService implements DiscountService {
@Override
public double getDiscount() {
return 20;
}
}
Loading