当前位置:首页计算机类软件水平考试中级软件设计师->阅读下列说明和java代码,将应填入(n)处字句写在答题纸对

阅读下列说明和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!

答案:
本题解析:

(1) ticket.printInvoice()

(2) ticket.printInvoice()

(3) ticket.printInvoice()

(4) new FootDecorator(new

更新时间:2022-08-01 06:49
纠错

你可能感兴趣的试题

单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.V(S2)和P(S4)
  • B.P(S2)和V(S4)
  • C.P(S2)和P(S4)
  • D.V(S2)和V(S4)
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.V(S1)P(S2)和V(S3)
  • B.P(S1)V(S2)和V(S3)
  • C.V(S1)V(S2)和V(S3)
  • D.P(S1)P(S2)和V(S3)
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.P(S4)和V(S4)V(S5)
  • B.V(S5)和P(S4)P(S5)
  • C.V(S3)和V(S4)V(S5)
  • D.P(S3)和P(S4)V(P5)
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.P(S3)和V(S4)V(S5)
  • B.V(S3)和P(S4)P(S5)
  • C.P(S3)和P(S4)P(S5)
  • D.V(S3)和V(S4)V(S5)
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.P(S2)和P(S4)
  • B.P(S2)和V(S4)
  • C.V(S2)和P(S4)
  • D.V(S2)和V(S4)
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.V(S1)、P(S1)和V(S2)V(S3)
  • B.P(S1)、V (S1)和V(S2)V(S3)
  • C.V(S1)、V(S2)和P(S1)V(S3)
  • D.P(S1)、V(S2)和V(S1)V(S3)
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.序列图
  • B.状态图
  • C.通信图
  • D.活动图
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.合并分叉
  • B.分支
  • C.合并汇合
  • D.流
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.产甲2套,乙3套
  • B.生产甲1套,乙4套
  • C.生产甲3套,乙4套
  • D.生产甲4套,乙2套
查看答案
单选题

高级系统分析师,专项练习,软件水平考试《高级系统分析师》押题

  • A.见图A
  • B.见图B
  • C.见图C
  • D.见图D
查看答案