-
Notifications
You must be signed in to change notification settings - Fork 17
Silpo points system #9
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
Open
myroslavsok
wants to merge
22
commits into
alexanderko:master
Choose a base branch
from
myroslavsok:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9cee2d9
added realisation to FactorByCategory and AnyGoodsOffer
MyroslavSokolov 92bae54
created check for expiratin date in offer (Template Method)
MyroslavSokolov 784006b
created halfPrise offer
MyroslavSokolov 65c80d7
can use offer before making goods
MyroslavSokolov e015a4d
created interfaces Reward and Condition
MyroslavSokolov b46e81c
Fixed bug with using offer. Now you can use it anytime you want
MyroslavSokolov ee1a201
realised FactorByCategoryReward
MyroslavSokolov e176770
created ByCategory condition
MyroslavSokolov bb97f90
created ByTotalCostCondition
MyroslavSokolov 0363047
realised DiscountReward
MyroslavSokolov 59e244d
add date expiration\
MyroslavSokolov d948d38
deleted extra classes
MyroslavSokolov ee6bd69
fixed bug with using offer during making bargains
MyroslavSokolov 7f1a668
refractore code
MyroslavSokolov 31a8c23
added AnyGoodsReward and fixed tests
MyroslavSokolov d32ed2b
fixed bugs with DiscountReward tests
MyroslavSokolov b425a2d
after fork\
MyroslavSokolov 0ed7634
used telescopic constructor in Offer, moved Offer's field dateOfCheck…
MyroslavSokolov e0a03c8
deleted AnyGoodsReward because it dublicates FlatReward
MyroslavSokolov 88a14d3
can use several offers
MyroslavSokolov 67e838b
cleaned code
MyroslavSokolov 97727f5
cleaned code
MyroslavSokolov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,5 +1,8 @@ | ||
| package checkout; | ||
|
|
||
| public enum Category { | ||
| MILK | ||
| MILK, | ||
| MEET, | ||
| FRUIT, | ||
| VEGETABLE | ||
| } |
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,5 +1,32 @@ | ||
| package checkout; | ||
|
|
||
| public abstract class Offer { | ||
| public abstract void apply(Check check); | ||
| } | ||
| import checkout.offer_interfaces.Condition; | ||
| import checkout.offer_interfaces.Reward; | ||
| import java.time.LocalDate; | ||
|
|
||
| public class Offer { | ||
|
|
||
| private LocalDate expiresDate; | ||
| private Reward reward; | ||
| private Condition condition; | ||
|
|
||
| public Offer(LocalDate expireDate, Reward rewardType) { | ||
| this(expireDate, rewardType, null ); | ||
| } | ||
|
|
||
| public Offer(LocalDate expireDate, Reward rewardType, Condition conditionType) { | ||
| this.expiresDate = expireDate; | ||
| this.reward = rewardType; | ||
| this.condition = conditionType; | ||
| } | ||
|
|
||
| void applyOffer(Check check) { | ||
| if (this.expiresDate.isAfter(check.getDateOfCheck())) | ||
| reward.applyReward(check); | ||
| } | ||
|
|
||
| boolean isOfferValid(Check check) { | ||
| return (condition == null) || condition.checkCondition(check); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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,26 @@ | ||
| package checkout.offer_conditions; | ||
|
|
||
| import checkout.Category; | ||
| import checkout.Check; | ||
| import checkout.offer_interfaces.Condition; | ||
|
|
||
| public class ByCategory implements Condition { | ||
|
|
||
| private Category requiredCategory; | ||
| private int requiredAmount; | ||
|
|
||
| public ByCategory(Category requiredCategory, int requiredAmount) { | ||
| this.requiredCategory = requiredCategory; | ||
| this.requiredAmount = requiredAmount; | ||
| } | ||
|
|
||
| public ByCategory(Category requiredCategory) { | ||
| this.requiredCategory = requiredCategory; | ||
| this.requiredAmount = 0; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean checkCondition(Check check) { | ||
| return (this.requiredAmount < check.getCostByCategory(this.requiredCategory)); | ||
| } | ||
| } |
This file contains hidden or 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,20 @@ | ||
| package checkout.offer_conditions; | ||
|
|
||
| import checkout.Check; | ||
| import checkout.offer_interfaces.Condition; | ||
|
|
||
| public class ByTotalCost implements Condition { | ||
|
|
||
| private int requiredAmount; | ||
|
|
||
| public ByTotalCost(int requiredAmount) { | ||
| this.requiredAmount = requiredAmount; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean checkCondition(Check check) { | ||
| return this.requiredAmount < check.getTotalCost(); | ||
| } | ||
|
|
||
| } | ||
|
|
This file contains hidden or 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 checkout.offer_interfaces; | ||
|
|
||
| import checkout.Check; | ||
|
|
||
| public interface Condition { | ||
| boolean checkCondition(Check check); | ||
| } |
This file contains hidden or 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 checkout.offer_interfaces; | ||
|
|
||
| import checkout.Check; | ||
|
|
||
| public interface Reward { | ||
| void applyReward(Check check); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.