/Benefit.java Secret
Created
May 23, 2021 04:34
Visitor pattern - visitor
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
interface Benefit { | |
public void getBenefit(RedLabelMd redLabel); | |
public void getBenefit(GreenLabelMd greenLabel); | |
} | |
class DiscountBenefit implements Benefit { | |
@Override | |
public void getBenefit(RedLabelMd redLabel) { | |
System.out.println("Apply Discount 50%"); | |
} | |
@Override | |
public void getBenefit(GreenLabelMd greenLabel) { | |
System.out.println("Apply Discount 10%"); | |
} | |
} | |
class PointBenefit implements Benefit { | |
@Override | |
public void getBenefit(RedLabelMd redLabel) { | |
System.out.println("Add Point 1%"); | |
} | |
@Override | |
public void getBenefit(GreenLabelMd greenLabel) { | |
System.out.println("Add Point 5%"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment