Complete the code to declare the Builder interface method for setting the product's name.
interface Builder {
Builder setName([1] name);
}int or boolean instead of String for the name parameter.void as a parameter type.The setName method should accept a String parameter representing the product's name.
Complete the code to return the built product from the Builder.
class ProductBuilder implements Builder { private Product product = new Product(); public Product [1]() { return product; } }
create or make which are less standard.getProduct which is verbose and less idiomatic.The standard method name to return the final product in the Builder pattern is build().
Fix the error in the Director class method to correctly use the Builder to construct a product.
class Director { public Product construct(Builder builder) { builder.setName("Toy"); builder.setPrice(10); return builder.[1](); } }
create() or make() instead of build().The Director calls the build() method on the Builder to get the final product.
Fill both blanks to complete the fluent interface methods in the Builder implementation.
class ProductBuilder implements Builder { private Product product = new Product(); public Builder setName([1] name) { product.name = name; return [2]; } }
void instead of this breaks chaining.product or void.The method parameter type is String for the name, and the method returns this to allow method chaining.
Fill all three blanks to complete the dictionary comprehension that maps product names to prices for products costing more than 100.
expensive_products = {product.[1]: product.[2] for product in products if product.[3] > 100}quantity instead of price in the condition.The dictionary maps product name to price for products where price is greater than 100.