题目详情

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

你可能感兴趣的试题

单选题

Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.

  • A.Artificial Intelligence
  • B.Cloud Computing
  • C.Internet of Things
  • D.Big Data
查看答案
单选题

In project human resource management , ( )is not a source of power for the project manager.

  • A.referent power
  • B.expert power
  • C.reward power
  • D.audit power
查看答案
单选题

At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.

  • A.detail feasibility analysis
  • B.opportunity analysis
  • C.economic feasibility analysis
  • D.risk analysis
查看答案
单选题

( )is a grid that shows the project resources assigned to each work package.

  • A.Stakeholder engagement assessment matrix
  • B.Requirements traceability matrix
  • C.Probability and impact matrix
  • D.Responsibility assignment matrix
查看答案
单选题

Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.

  • A.digital
  • B.networking
  • C.intelligentize
  • D.informatization
查看答案

相关题库更多 +