生成器(Builder)可以独立使用
生成器(Builder)可以独立使用
相关考题:
在J2EE中,接受一个XML文档,返回document对象,以分析该XML文档,可以使用如下()方法获得document对象 A.Documentdoc=DocumentBuilderFactory.parse(“my.xml”);B.Documentdoc=DocumentBuilder.parse(“my.xml”);C.DocumentBuilderFactorydbf=DocumentBuilderFactory.newInstance();DocumentBuilder builder=dbf.newDocumentBuilder();Documentdoc=builder.parse(“my.xml”);D.DocumentBuilderbuilder=newDocumentBuilder();Documentdoc=builder.parse(“my.xml”);
● 设计模式根据目的进行分类,可以分为创建型、结构型和行为型三种。其中结构型模式用于处理类和对象的组合。(44)模式是一种结构型模式。(44)A.适配器( Adapter)B.命令(Command)C.生成器(Builder)D.状态(State)
下面哪条语句可以构造正确的对话框()。 A.AlertDialog dialog=new AlertDialog(context);B.AlertDialog.Builder builder=new AlertDialog.Builder(context);C.ProgressDialog dialog=new ProgressDialog();D.ProgressDialog.Builder builder=new ProgressDialog.Builder(context);
阅读以下说明和Java代码,回答问题[说明]在某些系统中,存在非常复杂的对象,可以采用循序渐进的方式进行组合将小对象组合,成复杂的对象。以下实例展示了Builder(生成器)模式。该实例用来建立“文件”,文件内容包括:一个标题、一串字符以及一些有项目符号的项目。Builder类规定组成文件的方法,Director类利用这个方法产生一份具体的文件。图6-1显示了各个类间的关系。以下是Java语言实现,能够正确编译通过。[Java代码]//Builder. java文件public (1) class Builder {public abstract void makeTitle(String title);public abstract void makeString(String str);public abstract void makeItems(String[] items);public abstract Object getResult();}//Director. java文件public class Director{private (2) builder;public Director(Builder builder){this. builder = builder;}public Object construct(){builder.makeTitle("Greeting");builder.makeString("从早上到白天结束");builder.makeItems(new String[]{"早安", "午安",});builder.makeString("到了晚上");builder.makeItems(new String[]("晚安", "好梦",});return builder.getResult();}}//TextBuilder.java文件public class TextBuilder (3) Builder{private StringBuffer buffer = new StringBuffer();public void makeTitle(String title){buffer.append("『" + title + "』"\n\n");}public void makeString(String str){buffer.append('■' + str + "\n\n ");}public void makeItems(String[] items){for(int i = 0; i (4) ; i++){buffer.append('·' + items[i] + "\n");}buffer.append("\n");}public Object getResult(){return buffer.toString();}}//Main.java文件public class Main {public static void main(String[] args) {Director director = new Director(new TextBuilder());String result = (String)director. (5) ;System.out.println(result);
下图所示为 (46) 设计模式,适用于 (47) 。A.抽象工厂(Abstract Factory)B.生成器(Builder)C.工厂方法(Factory Method)D.原型(Prototype)
下图所示为 (请作答此空) 设计模式,适用于 ( ) 。A.抽象工厂(Abstract Factory)B.生成器(Builder)C.工厂方法(Factory Method)D.原型(Prototype)
阅读下列说明和 C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】生成器( Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图 5-1 所示为其类图。【C++代码】#include #include using namespace std;class Product {private:? ??string partA, partB;public:Product() {?? }? ? ?voidsetPartA(const string}???? voidsetPartB(const string}//? 其余代码省略};class Builder {public:??????? (1)?? ;virtual void buildPartB()=0;??????? (2)?? ;};class ConcreteBuilder1 : public Builder {private:Product*?? product;public:ConcreteBuilder1() {product = new Product();???? }??? voidbuildPartA() {????? (3)???? ("Component A"); }??? voidbuildPartB() {????? (4)???? ("Component B"); }Product* getResult() { return product; }//? 其余代码省略};class ConcreteBuilder2 : public Builder {? ??/*??? 代码省略??? */};class Director {private:?Builder* builder;public:? ?Director(Builder* pBuilder) { builder= pBuilder;}???? voidconstruct() {? ? ? ? ? ? ? (5)???? ;? ? ?//? 其余代码省略????? }//? 其余代码省略};int main() {Director* director1 = new Director(new ConcreteBuilder1());?director1->construct();? ?delete director1;? ??return 0;
( )模式将一个复杂对象的构建与其表示分离,使得同样的构建过程可以创 建不同的表示。A.生成器(Builder) B.工厂方法(FactoryMethod) C.原型(Prototype) D.单例(Singleton)
下图所示为(46)设计模式,适用于(47)。A.抽象工厂(A.bstrA.ct FA.ctory)B.生成器(Builder)C.工厂方法(FA.ctory Method)D.原型(Prototype)
阅读下列说明和 Java 代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】生成器( Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图 6-1 所示为其类图。阅读下列说明和C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】???? 生成器(Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图5-1所示为其类图。?【C++代码】#include #include using namespace std;class Product {private:?string partA, partB;public:?Product() {?? }? ?void setPartA(const string}???? void setPartB(const string}? ?//? 其余代码省略};class Builder {public:? ? ??(1)??;?virtual void buildPartB()=0;? ? ?(2)??;};class ConcreteBuilder1 : public Builder {private:?Product*?? product;public:ConcreteBuilder1() {product = new Product();???? }void buildPartA() {????? (3)???? ("ComponentA"); }?void buildPartB() {????? (4)???? ("ComponentB"); }??Product* getResult() { return product; }//? 其余代码省略};class ConcreteBuilder2 : public Builder {? ??? ? ? ?/*??? 代码省略??? */};class Director {private:? ??Builder* builder;public:??Director(Builder* pBuilder) { builder= pBuilder;}? ??void construct() {????????????????? (5)???? ;?????????????? //? 其余代码省略? ?}??//? 其余代码省略};int main() {? ? ??Director* director1 = new Director(new ConcreteBuilder1());? ?director1->construct();? ? ??delete director1;? ? ?return 0;【Java代码】import jav(6)A.util.*;class Product {? ? ? ?private String partA;? ? ? ?private String partB;? ? ? ??public Product() {}? ? ??public void setPartA(String s) { partA = s; }? ? ? ?public void setPartB(String s) { partB = s; }}interface Builder {? ?public?????? (1)???? ;? ??public void buildPartB();? ? ??public?????? (2)???? ;}class ConcreteBuilder1 implements Builder {? ? ? ?private Product product;? ? ? ?public ConcreteBuilder1() { product = new Product();?? }? ? ? ??public void buildPartA() {????????(3)??("Component A"); }public void buildPartB() {???? ????(4)?? ("Component B"); }? ? ??public Product getResult() { return product;}}class ConcreteBuilder2 implements Builder {?? ? ? ? ?//? 代码省略}class Director {? ? ? ?private Builder builder;? ? ? ?public Director(Builder builder) {this.builder = builder; }public void construct() {? ? ? ? ? ? ? ? ? (5)???? ;? ? ? ? ? ? ? //? 代码省略? ? ??}}class Test {? ? ??public static void main(String[] args) {???????????????? Director director1 = newDirector(new ConcreteBuilder1());???????????????? director1.construct();? ? ? ??}
The IT department is creating a human resources application that will require several new tables. You need to develop a standard alone executable that will defines these tables and their relationships. Which developer/2000 component could you use to create the executable?()A、Procedure builder. B、Query builder. C、Schema builder. D、Form builder. E、Project builder. F、Transactional builder.
单选题The IT department is creating a human resources application that will require several new tables. You need to develop a standard alone executable that will defines these tables and their relationships. Which developer/2000 component could you use to create the executable?()AProcedure builder. BQuery builder. CSchema builder. DForm builder. EProject builder. FTransactional builder.
单选题在J2EE中,接受一个XML文档,返回document对象,以分析该XML文档,可以使用如下()方法获得document对象ADocument doc=DocumentBuilderFactory.parse(“my.xml”);BDocument doc=DocumentBuilder.parse(“my.xml”);CDocumentBuilderFactory dbf= DocumentBuilderFactory.newInstance(); DocumentBuilder builder=dbf.newDocumentBuilder(); Document doc=builder.parse(“my.xml”);DDocumentBuilder builder=new DocumentBuilder(); Document doc=builder.parse(“my.xml”);
判断题Size Class只能在Interface Builder中来使用。A对B错