Skip to content

Instantly share code, notes, and snippets.

@mhtmalpani
Created November 26, 2017 19:36
Show Gist options
  • Save mhtmalpani/d76ffbc79b28aecacd5fd394bc318eef to your computer and use it in GitHub Desktop.
Save mhtmalpani/d76ffbc79b28aecacd5fd394bc318eef to your computer and use it in GitHub Desktop.
The Client code for Builder with Twist.
public class Main {
public static void main(String[] args) {
Subway subwayVegetarian = Subway.builder().bread("Wheat")
.toast(true)
.veg()
.olives().tomato().onion()
.prepare()
.cheese("Mozzarella")
.build();
Subway subwayNonVegChicken = Subway.builder().bread("Parmesan Oregano")
.toast(false)
.nonVeg()
.chicken()
.olives().tomato()
.prepare()
.cheese("Cheddar")
.build();
Subway subwayNonVegMutton = Subway.builder().bread("Italian White")
.toast(true)
.nonVeg()
.mutton()
.tomato().onion()
.prepare()
.build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment