摘要:希賽網(wǎng)整理了2017上半年軟件設(shè)計(jì)師考試下午真題,以下是第六部分。
>>>>點(diǎn)擊進(jìn)入了解軟件設(shè)計(jì)師培訓(xùn)視頻
>>>>點(diǎn)擊進(jìn)入了解軟件設(shè)計(jì)師面授班
希賽網(wǎng)整理了2017上半年軟件設(shè)計(jì)師考試下午真題,以下是第六部分。
試題六(共15分)
閱讀下列說(shuō)明和Java代碼,將應(yīng)填入(n)處的字句寫在答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
某快餐廳主要制作并出售兒童套餐,一般包括主餐(各類比薩)、飲料和玩具,其餐品種類可能不同,但其制作過程相同。前臺(tái)服務(wù)員(Waiter)調(diào)度廚師制作套餐?,F(xiàn)采用生成器(Builder)模式實(shí)現(xiàn)制作過程,得到如圖6-1所示的類圖。
【Java代碼】
class Pizza {
private String parts;
public void setParts(String parts) {this.parts = parts;}
public String toString() {return this.parts;}
}
abstract class PizzaBuilder {
protected Pizza pizza;
public Pizza getPizza() {return pizza;}
public void createNewPizza() { pizza = new Pizza();}
public (1) ;
}
class HawaiianPizzaBuilder extends PizzaBuilder {
public void buildParts() {pizza.setParts("cross + mild + ham&pineapp1e”};
}
class SpicyPizzaBuilder extends PizzaBuilder {
public void buildParts() { pizza.setParts("pan baked + hot + pepperoni&salami");}
}
class Waiter {
private PizzaBuilder pizzaBuilder;
public void setPizzaBuilder(PizzaBuilder pizzaBuilder) { /*設(shè)置構(gòu)建器*/
(2) ;
}
public Pizza getPizza(){ return pizzaBuilder.getPizza(); }
public void construct() {/*構(gòu)建*/
pizzaBuilder.createNewPizza();
(3) ;
}
}
Class FastFoodOrdering {
public static viod mainSting[]args) {
Waiter waiter = new Waiter();
PizzaBuilder hawaiian_pizzabuilder = new HawaiianPizzaBuilder();
(4);
(5);
System.out.println("pizza: " + waiter.getPizza());
}
}
程序的輸出結(jié)果為:
Pizza:cross+mild+ham&pineapple
>>>返回目錄:2017上半年軟件設(shè)計(jì)師考試下午真題匯總
軟考備考資料免費(fèi)領(lǐng)取
去領(lǐng)取
共收錄117.93萬(wàn)道題
已有25.02萬(wàn)小伙伴參與做題