Created
March 6, 2012 20:29
-
-
Save sandromancuso/1988792 to your computer and use it in GitHub Desktop.
This file contains 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
public class ProductBuilder { | |
private double price; | |
private String name; | |
public static ProductBuilder aProduct() { | |
return new ProductBuilder(); | |
} | |
public ProductBuilder costing (double price) { | |
this.price = price; | |
return this; | |
} | |
public ProductBuilder named(String name) { | |
this.name = name; | |
return this; | |
} | |
public Product build() { | |
Product product = new Product(); | |
product.setPrice(price); | |
product.setName(name); | |
return product; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment