网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
阅读下列说明和java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
【说明】
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。
【java代码】
class invoice{
public void printInvoice( ){
System.out.println ( "This is the content of the invoice!");
}
}
class Decorator extends Invoice {
protected Invoice ticket;
public Decorator(lnvoice t){
ticket = t;
}
public
void printInvoice( ){
if(ticket != null)
(1) ;
}
}
class HeadDecorator extends Decorator{
public HeadDecorator(lnvoice t){
super(t);
}
public void printInvoice ( ){
Systent.out.println( "This is the header of the invoice! ");
(2) ;
}
}
class FootDecorator extends Decorator {
public FootDecorator(Invoice t){
super(t);
}
public void printlnvoice( ){
( 3) ;
Systent.out.println( "This is the footnote of the invoice! ");
}
}
Class test {
public static void main(String[] args){
Invoice t =new Invioce( );
Invoice ticket;
ticket= (4) ;
ticket.printInvoice( );
Systent.out.println(“------------------“);
ticket= (5) ;
ticket.printInvoice( );
}
}
程序的输出结果为:
This is the header of the invoice!
This is the content of the invoice!
This is the footnote of the invoice!
----------------------------
This is the header of the invoice!
This is the footnote of the invoice!
【说明】
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。
【java代码】
class invoice{
public void printInvoice( ){
System.out.println ( "This is the content of the invoice!");
}
}
class Decorator extends Invoice {
protected Invoice ticket;
public Decorator(lnvoice t){
ticket = t;
}
public
void printInvoice( ){
if(ticket != null)
(1) ;
}
}
class HeadDecorator extends Decorator{
public HeadDecorator(lnvoice t){
super(t);
}
public void printInvoice ( ){
Systent.out.println( "This is the header of the invoice! ");
(2) ;
}
}
class FootDecorator extends Decorator {
public FootDecorator(Invoice t){
super(t);
}
public void printlnvoice( ){
( 3) ;
Systent.out.println( "This is the footnote of the invoice! ");
}
}
Class test {
public static void main(String[] args){
Invoice t =new Invioce( );
Invoice ticket;
ticket= (4) ;
ticket.printInvoice( );
Systent.out.println(“------------------“);
ticket= (5) ;
ticket.printInvoice( );
}
}
程序的输出结果为:
This is the header of the invoice!
This is the content of the invoice!
This is the footnote of the invoice!
----------------------------
This is the header of the invoice!
This is the footnote of the invoice!
参考答案
参考解析
解析: (1) ticket.printInvoice()
(2) ticket.printInvoice()
(3) ticket.printInvoice()
(4) new FootDecorator(new
(2) ticket.printInvoice()
(3) ticket.printInvoice()
(4) new FootDecorator(new
更多 “阅读下列说明和java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。 【java代码】 class invoice{ public void printInvoice( ){ System.out.println ( "This is the content of the invoice!"); } } class Decorator extends Invoice { protected Invoice ticket; public Decorator(lnvoice t){ ticket = t; } public void printInvoice( ){ if(ticket != null) (1) ; } } class HeadDecorator extends Decorator{ public HeadDecorator(lnvoice t){ super(t); } public void printInvoice ( ){ Systent.out.println( "This is the header of the invoice! "); (2) ; } } class FootDecorator extends Decorator { public FootDecorator(Invoice t){ super(t); } public void printlnvoice( ){ ( 3) ; Systent.out.println( "This is the footnote of the invoice! "); } } Class test { public static void main(String[] args){ Invoice t =new Invioce( ); Invoice ticket; ticket= (4) ; ticket.printInvoice( ); Systent.out.println(“------------------“); ticket= (5) ; ticket.printInvoice( ); } } 程序的输出结果为: This is the header of the invoice! This is the content of the invoice! This is the footnote of the invoice! ---------------------------- This is the header of the invoice! This is the footnote of the invoice!” 相关考题
考题
●试题四阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。【函数】void QuickSort(int A[],int s,int t){int i=s,j=t+1,temp;int x=A[s];do{do i++;while (1) ;do j--;while(A[j]x);if(ij){temp=A[i]; (2) ; (3) ;}}while(ij);A[a]=A[j];A[j]=x;if(si-1) (4) ;if(j+1t) (5) ;}
考题
阅读以下说明、Java代码和HTML文档,将应填入(n)处的字句写在答题纸的对应栏内。【说明】当用户启动html浏览器并首次打开下面的HTML文档时,Java Applet小程序在显示面板上显示字符串“Welcome!”;当html页面被其他窗口遮挡后再次显示时,小程序在显示面板上显示“Welcome back!”。【Java代码】import javA.awt.*;import javA.applet;public class HelloApplet extends (1) {public void paim((2)){g.drawString(message,10,20);message="welcome back!”;}public void (3) (){message="Welcome!”;}private (4) message;}【HTML文档】<html><head><title>HTML Test HelloApplet Page</title></head><body>Test HelloApplet小程序<br><appletcodebase="."code="(5) "name="TestApplet"width="400"height="300"></applet></body></html>
考题
阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。【说明】已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:
考题
阅读下列函数说明和C代码,将应填入(n)处的字句写在对应栏内。【说明】函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。【函数】void QuickSort( int A[ ],int s,int t){ int i=s,j=t+1,temp;int x=A[s];do{do i ++ ;while (1);do j -- ;while(A[j]>x);if(i<j){temp=A[i];(2);(3);}}while(i<j);A[a] =A[j];A[j] =x;if(s<i-1) (4);if(j+1<t) (5);}
考题
阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]设学生某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图读取该文件,统计出全部成绩中的最高分max和最低分min。
考题
阅读下面的说明,回答问题1~问题4,将解答填入答题纸对应的解答栏内。[说明]阅读以下说明,回答问题1~问题4,将解答填入答题纸对应的解答栏内。windows Server 2003是一个多任务多用户的操作系统,能够以集中或分布的方式实现各种应用服务器角色,是目前应用比较广的操作系统之一。Windows内置许多应用服务功能,将下表中(1)~(5)处空缺的服务器名称填写在答题纸对应的解答栏内。(1)
考题
阅读以下说明和Java以及HTML代码,将应填入(n)处的字句写在对应栏内。[说明]编写一个Applet程序,接受HTML文件传递的整数参数,根据该参数指定Applet中文本框的长度。编写对应的HTML文件运行这个Applet。[Java 代码]import java. applet.*;import java. awt.*;public class chuangdics extends (1){TextField tf=new TextField ();int tfLength=0;public void init(){try{tfLength=Integer. parseInt( (2) ("length"));tf. setColumns (tfLength);add (tf);}catch (NumberFormatException nfe){tf. (3) ("HTML 文件传人的参数格式错误。");add(tf);}}}[HTML 代码]<html><head><title>(4)</title></head><body><hr><applet code=chuangdics width=700 height=150><param name=length value=20>(5)<hr></body></htmI>
考题
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。【说明】阅读下面几段C++程序回答相应问题。比较下面两段程序的优缺点。①for (i=0; i<N; i++ ){if (condition)//DoSomething…else//DoOtherthing…}②if (condition) {for (i =0; i<N; i++ )//DoSomething}else {for (i=0; i <N; i++ )//DoOtherthing…}
考题
阅读以下说明和Java程序,填补代码中的空缺(1)~(6),将解答填入答题纸的对应栏内。【说明】很多依托扑克牌进行的游戏都要先洗牌。下面的Java代码运行时先生成一副扑克牌,洗牌后再按顺序打印每张牌的点数和花色。【Java代码】
考题
阅读下列说明和c++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。Command模式的类图如图5-1所示。【c++代码】}
考题
阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。command模式的类图如图6-1所示。【Java代码】}
考题
●试题二阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】该程序运行后,输出下面的数字金字塔【程序】includestdio.hmain (){char max,next;int i;for(max=′1′;max=′9′;max++){for(i=1;i=20- (1) ;++i)printf(" ");for(next= (2) ;next= (3) ;next++)printf("%c",next);for(next= (4) ;next= (5) ;next--)printf("%c",next);printf("\n");}}
考题
●试题一阅读下列说明和流程图,将应填入(n)的字句写在答题纸的对应栏内。【说明】下列流程图(如图4所示)用泰勒(Taylor)展开式sinx=x-x3/3!+x5/5!-x7/7!+…+(-1)n×x 2n+1/(2n+1)!+…【流程图】图4计算并打印sinx的近似值。其中用ε(0)表示误差要求。
考题
下图是基于软交换的网络分层模型简图,其中(1)、(2) 为网络层次,(3)、(4)、(5)为软交换系统中的设备。请根据简图将应填入( )处的字句 写在答题纸对应的解答栏内,括号内数字相同处代表同一字句,( n )相同者只计2分)基于软件交换的网络分层模型简图
考题
阅读下列说明和 C ++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某软件公司欲开发一款汽车竞速类游戏,需要模拟长轮胎和短轮胎急刹车时在路面上留 下的不同痕迹,并考虑后续能模拟更多种轮胎急刹车时的痕迹。现采用策略(Strategy)设计模式来实现该需求,所设计的类图如图 6-1 所示。
【C++ 代码】#includeusing namespace std;class BrakeBehavior{public:(1) ; /*其余代码省略*/};class LongWheelBrake : public BrakeBehavior{public:void stop(){cout
考题
阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。
【C++代码】 #include using namespace std; class invoice{ public: (1){ cout
考题
阅读下列说明和C++代码,回答问题,将解答填入答题纸的对应栏内。
【说明】某航空公司的会员积分系统将其会员划分为:普卡 (Basic)、银卡(Silver)和金卡 (Gold) 三个等级。非会员 (NonMember) 可以申请成为普卡会员。会员的等级根据其一年内累积 的里程数进行调整。描述会员等级调整的状态图如图 5-1 所示。现采用状态 (State) 模式实现上述场景,得到如图 5-2 所示的类图。
【问题1】(15分)阅读上述说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
考题
阅读下列说明和 Java 代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某软件公司欲开发一款汽车竞速类游戏,需要模拟长轮胎和短轮胎急刹车时在路面上 留 下的不同痕迹,并考虑后续能模拟更多种轮胎急刹车时的痕迹。现采用策略(Strategy) 设 计模式来实现该需求,所设计的类图如图 5-1 所示。
考题
阅读下列说明和 Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某航空公司的会员积分系统将其会员划分为:普卡 (Basic) 、银卡(Silver)和金卡 (Gold)三个等级。非会员 (NonMember)可以申请成为普卡会员。会员的等级根据其 一年内累积的里程数进行调整。描述会员等级调整的状态图如图 6-1 所示 。现采用状态 (State) 模式实现上述场景,得到如图 6-2 所示的类图。
考题
阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 某文件管理系统中定义了类OfficeDoc和DocExplorer,当类OfficeDoc发生变化时,类DocExplorer的所有对象都要更新其自身的状态,现采用观察者(Observer)设计模式来实现该需求,所设计的类图如图6-1所示。
考题
阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。
【说明】
某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种
类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。
热门标签
最新试卷