第1页共7页编号:时间:2021年x月x日书山有路勤为径,学海无涯苦作舟页码:第1页共7页三、请书写一个类,该类只能产生同一个对象
(10分)PublicclassSingleton{PrivatestaticfinalSingletonsingleton=newSingleton();PrivateSingleton(){}PublicstaticSingletongetInstance(){Returnsingleton;}}四、程序补充题
(2*10分)1
观察者模式请根据以上类图填充完整下面的程式源码
publicinterfaceSubject{publicvoidregisterObserver(Observero);publicvoidremoveObserver(Observero);publicvoidnotifyObserver();厦门大学《软件体系结构》课程试卷软件学院系2010秋季年级软件工程专业主考教师:王备战试卷类型:(A卷)第2页共7页第1页共7页编号:时间:2021年x月x日书山有路勤为径,学海无涯苦作舟页码:第2页共7页}publicinterfaceObserver{Publicvoidupdate(floattemp,floathumidity,floatpressure);}publicinterfaceDisplayElement{publicvoiddisplay();}publicclassWeatherDataimplementSubject{privateArrayListobservers;privatefloattemperature;privatefloathumidity;privatefloatpressure;publicWeatherData(){observers=newArrayList();}publi