阅读以下说明和Java程序代码,将应填入(n)处的字句写在答题纸的对应栏内。
[说明]
在下面的Java程序代码中,类SalesTicket能够完成打印票据正文的功能,类 HeadDecorator与FootDecorator分别完成打印票据的抬头和脚注的功能。己知该程序运行后的输出结果如下所示,请填补该程序代码中的空缺。
这是票据的抬头!
这是票据正文!
这是票据的脚注!
---------------------------------------
这是票据的抬头!
这是票据的脚注!
[Java程序代码]
public class SalesTicket
public void printTicket()
System.out.println("这是票据正文!");
public class Decorator extends SalesTicket
SalesTicket ticket;
public Decorator(SalesTicket t)
ticket =t;
public void printTicket()
if(ticket!=null)
ticket. printTicket();
public class HeadDecorator extends Decorator
public HeadDecorator(SalesTicket t)
(1) ;
public void printTicket()
System.out.rintln("这是票据的抬头!");
Super.printTicket();
public class FootDecorator extends Decorator
public FootDecorator(SalesTicket t)
(2) ;
public void printTicket()
super.printTicket();
System.out.println("这是票据的脚注!");
public class Main
public static void main(String[] args)
Decorator T=
new HeadDecorator( (3) );
T. (4) ;
System.out.println("-----------------------------------------");
T=new FootDecorator( (5) );
T.printTicket();