2017年上半年软件设计师下午真题试卷 下载本文

pizza。setParts(\); } }

class SpicyPizzaBuilder extends PizzaBuilder{

public void buildParts(){

pizza。setParts(\} }

class Waiter{

private PizzaBuilder pizzaBuilder;

public void setPizzaBuilder(PizzaBuilder pizzaBuilder){

/*设置构建器*/ ( 2 ); }

public Pizza getPizza(){ return pizzaBuilder。getPizza(); } public void construct() { /*构建*/

pizzaBuilder。createNewPizza(); ( 3 ); } }

Class FastFoodOrdering{

public static viod mainSting[]args){

Waiter waiter = new Waiter();

PizzaBuilder hawaiian_pizzabuilder = new HawaiianPizzaBuilder(); ( 4 ) ; ( 5 ) ;

System。out。println(\。getPizza()); } }

程序的输出结果为:

Pizza:cross + mild + ham&pineapple

答案解析:

(1)abstract void buildParts(); (2)=pizzaBuilder (3)()

(4)(hawaiian_pizzabuilder) (5)()