Lab Manuals for
Software Construction
Lab-3
Reusability and Maintainability oriented Software Construction
Faculty of Computing Harbin Institute of Technology Spring 2021
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
1 2 3
Ŀ¼
ʵÑéÄ¿±ê …………………………………………………………………………………………………………………………… 2 ʵÑé»·¾³ …………………………………………………………………………………………………………………………… 2 ʵÑéÒªÇó …………………………………………………………………………………………………………………………… 2
3.1 »ù±¾¸ÅÄî ……………………………………………………………………………………. ´íÎó!䶨ÒåÊéÇ©¡£
3.2 ´ý¿ª·¢µÄÓ¦Óó¡¾°…………………………………………………………………………………………………….3
3.3 ÃæÏò¿É¸´ÓÃÐԺͿÉά»¤ÐÔµÄÉè¼Æ:PlanningEntry
3.3.1 PlanningEntry
3.3.2 ¸÷Ó¦ÓõĸöÐÔ»¯ÌØÕ÷ ……………………………………………………….. ´íÎó!䶨ÒåÊéÇ©¡£
3.3.3 ÃæÏò¸÷Ó¦ÓÃµÄ PlanningEntry ×ÓÀàÐÍ………………………………………………………..12
3.3.4 PlanningEntry ¼°ÆäËùÓÐ×ÓÀàÐ͵IJâÊÔÓë×¢ÊÍ …………. ´íÎó!䶨ÒåÊéÇ©¡£
3.4 ÃæÏò¸´ÓõÄÉè¼Æ:R ………………………………………………………………………………………………..12
3.5 ÃæÏò¸´ÓõÄÉè¼Æ:Location………………………………………………….. ´íÎó!䶨ÒåÊéÇ©¡£
3.6 ÃæÏò¸´ÓõÄÉè¼Æ:Timeslot………………………………………………….. ´íÎó!䶨ÒåÊéÇ©¡£
3.7 ÃæÏò¸´ÓõÄÉè¼Æ:EntryState……………………………………………… ´íÎó!䶨ÒåÊéÇ©¡£
3.8 ÃæÏòÓ¦ÓõÄÉè¼Æ:Board ………………………………………………………… ´íÎó!䶨ÒåÊéÇ©¡£
3.9 Íⲿ API ¸´Óà …………………………………………………………………………… ´íÎó!䶨ÒåÊéÇ©¡£
3.10 ¿É¸´Óà API Éè¼Æ …………………………………………………………………… ´íÎó!䶨ÒåÊéÇ©¡£
3.11 Éè¼ÆģʽӦÓÃ……………………………………………………………………………………………………….13
3.12 Ó¦ÓÃÉè¼ÆÓëʵÏÖ …………………………………………………………………………………………………..14
3.13 »ùÓÚÓï·¨µÄÊý¾Ý¶ÁÈë …………………………………………………………………………………………..15
3.14 еı仯……………………………………………………………………………………………………………….16
3.15 ÏîÄ¿½á¹¹……………………………………………………………………………………………………………….17
ʵÑ鱨¸æ ………………………………………………………………………………………………………………………….18 Ìá½»·½Ê½ ………………………………………………………………………………………………………………………….18 ÆÀ·Ö·½Ê½ ………………………………………………………………………………………………………………………….18
4 5 6
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
1 ʵÑéÄ¿±ê
±¾´ÎʵÑ鸲¸Ç¿Î³ÌµÚ 2¡¢3 ÕµÄÄÚÈÝ£¬Ä¿±êÊDZàд¾ßÓпɸ´ÓÃÐԺͿÉά»¤ÐÔ µÄÈí¼þ£¬Ö÷ҪʹÓÃÒÔÏÂÈí¼þ¹¹Ôì¼¼Êõ:
l ×ÓÀàÐÍ¡¢·ºÐÍ¡¢¶à̬¡¢ÖØд¡¢ÖØÔØ
l ¼Ì³Ð¡¢´úÀí¡¢×éºÏ
l Óï·¨Çý¶¯µÄ±à³Ì¡¢ÕýÔò±í´ïʽ
l APIÉè¼Æ¡¢API¸´Óà ±¾´ÎʵÑé¸ø¶¨ÁËÈý¸ö¾ßÌåÓ¦ÓÃ(Öµ°à±í¹ÜÀí¡¢²Ù×÷ϵͳ½ø³Ìµ÷¶È¹ÜÀí¡¢´óѧ
¿Î±í¹ÜÀí)£¬Ñ§Éú²»ÊÇÖ±½ÓÕë¶Ôÿ¸öÓ¦Ó÷ֱð±à³ÌʵÏÖ£¬¶øÊÇͨ¹ý ADT ºÍ·ºÐÍµÈ ³éÏó¼¼Êõ£¬¿ª·¢Ò»Ì׿ɸ´ÓÃµÄ ADT ¼°ÆäʵÏÖ£¬³ä·Ö¿¼ÂÇÕâЩӦÓÃÖ®¼äµÄÏàËÆÐÔ ºÍ²îÒìÐÔ£¬Ê¹ ADT Óиü´ó³Ì¶ÈµÄ¸´ÓÃ(¿É¸´ÓÃÐÔ)ºÍ¸üÈÝÒ×ÃæÏò¸÷Öֱ仯(¿É ά»¤ÐÔ)¡£
2 ʵÑé»·¾³
ʵÑé»·¾³ÉèÖÃÇë²Î¼û Lab-0 ʵÑéÖ¸ÄÏ¡£
±¾´ÎʵÑéÔÚ GitHub Classroom ÖÐµÄ URL µØַΪ: https://classroom.github.com/a/ZAJ8w2eC
Çë·ÃÎʸà URL£¬°´ÕÕÌáʾ½¨Á¢×Ô¼ºµÄ Lab3 ²Ö¿â²¢¹ØÁªÖÁ×Ô¼ºµÄѧºÅ¡£
±¾µØ¿ª·¢Ê±£¬±¾´ÎʵÑéÖ»Ð轨Á¢Ò»¸öÏîÄ¿£¬Í³Ò»Ïò GitHub ²Ö¿âÌá½»¡£ÊµÑé°ü º¬µÄ¶à¸öÈÎÎñ·Ö±ðÔÚ²»Í¬µÄ°üÄÚ¿ª·¢£¬¾ßÌåĿ¼×éÖ¯·½Ê½²Î¼û¸÷ÈÎÎñ×îºóÒ»²¿·Ö µÄ˵Ã÷¡£ÇëÎñ±Ø×ñÑĿ¼½á¹¹£¬ÒÔ±ãÓÚ½Ìʦ/TA ½øÐвâÊÔ¡£
3 ʵÑéÒªÇó
±¾ÊµÑéÐèÒªÉè¼Æ²¢ÊµÏÖ³éÏóÊý¾ÝÀàÐÍ IntervalSet£¬¶ÔÏÖʵÖи÷Àà¡°ÔÚÌض¨ ʱ¼ä¶Î½øÐеÄÌض¨ÈÎÎñ¡±½øÐгéÏ󣬲¢ÔÚÈý¸ö¾ßÌåÓ¦ÓÃÖÐʹÓÃËü¡£
ÔÚÉè¼Æ¸Ã ADT ʱ£¬ÐèÒª¶ÔÆä½øÐзºÐÍ»¯£¬´Ó¶øʹÆä³éÏóÄÜÁ¦¸üÇ¿¡¢ÊÊÓ¦ÏÖ ÊµÖв»Í¬Çé¿öÐèÇóµÄÄÜÁ¦¸üÇ¿¡£
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
ÇëΪÿ¸öÄãÉè¼ÆºÍʵÏÖµÄ ADT ׫д mutability/immutability ˵Ã÷¡¢AF¡¢RI¡¢
3.1 ´ý¿ª·¢µÄÓ¦Óó¡¾°
ҪΪÒÔϳ¡¾°¿ª·¢ Java ³ÌÐò£¬¹ÊÔÚÉè¼ÆºÍʵÏÖ ADT µÄʱºòÐè³ä·Ö¿¼ÂÇÕâЩ Ó¦ÓÃÖ®¼äµÄÏàËÆÐԺͲîÒìÐÔ£¬Ê¹ ADT Óиü´ó³Ì¶ÈµÄ¸´Óú͸üÈÝÒ×ÃæÏò¸÷Öֱ仯¡£
(1) Öµ°à±í¹ÜÀí(DutyRoster):Ò»¸öµ¥Î»ÓÐn¸öÔ±¹¤£¬ÔÚij¸öʱ¼ä¶ÎÄÚ(Àý È纮¼Ù 1 Ô 10 ÈÕµ½ 3 Ô 6 ÈÕÆÚ¼ä)£¬Ã¿ÌìÖ»ÄÜ°²ÅÅΨһһ¸öÔ±¹¤ÔÚµ¥Î» Öµ°à£¬ÇÒ²»ÄܳöÏÖijÌìÎÞÈËÖµ°àµÄÇé¿ö;ÿ¸öÔ±¹¤Èô±»°²ÅÅÖµ°à m Ìì (m>1)£¬ÄÇôÐèÒª°²ÅÅÔÚÁ¬ÐøµÄ m ÌìÄÚ¡£Öµ°à±íÄÚÐèÒª¼Ç¼Ա¹¤µÄÃû ×Ö¡¢Ö°Î»¡¢ÊÖ»úºÅÂ룬ÒÔ±ãÓÚÍâ½çÁªÏµÖµ°àÔ±¡£
safety from rep exposure¡£¸ø³ö¸÷ ADT ÖÐÿ¸ö·½·¨µÄ spec¡£ÎªÃ¿¸ö ADT ±àд²â
ÊÔÓÃÀý£¬²¢Ð´Ã÷ testing strategy¡£
ÈÕÆÚ
Öµ°àÈËÃû×Ö
ְλ
ÊÖ»úºÅÂë
2021-01-10
Ëï XX
Êé¼Ç
13900000000
2021-01-11
Ëï XX
Êé¼Ç
13900000000
2021-01-12
Ëï XX
Êé¼Ç
13900000000
2021-01-13
Áõ XX
Ö÷ÈÎ
13811111111
2021-01-14
ÕÅ XX
Ôº³¤
18266666666
2021-01-15
ÕÅ XX
Ôº³¤
18266666666
2021-01-16
Íõ XX
¸±Ôº³¤
18677777777
2021-01-17
Íõ XX
¸±Ôº³¤
18677777777
2021-01-18
Úù XX
¸±Ö÷ÈÎ
15533333333
…
(2) ²Ù×÷ϵͳ½ø³Ìµ÷¶È¹ÜÀí(ProcessSchedule):¿¼ÂǼÆËã»úÉÏÓÐÒ»¸öµ¥ºË CPU£¬¶à¸ö½ø³Ì±»²Ù×÷ϵͳ´´½¨³öÀ´£¬ËüÃDZ»µ÷¶ÈÔÚ CPU ÉÏÖ´ÐУ¬Óɲ٠×÷ϵͳ¾ö¶¨ÔÚ¸÷¸öʱ¶ÎÄÚÖ´ÐÐÄĸöÏ̡߳£²Ù×÷ϵͳ¿É¹ÒÆðij¸öÕýÔÚÖ´ÐÐ µÄ½ø³Ì£¬ÔÚºóÐøʱ¿Ì¿ÉÒÔ»Ö¸´Ö´Ðб»¹ÒÆðµÄ½ø³Ì¡£¿ÉÖª:ÿ¸öʱ¼äÖ»ÄÜ ÓÐÒ»¸ö½ø³ÌÔÚÖ´ÐУ¬ÆäËû½ø³Ì´¦ÓÚÐÝÃß״̬;Ò»¸ö½ø³ÌµÄÖ´Ðб»·ÖΪ¶à ¸öʱ¼ä¶Î;ÔÚÌض¨Ê±¿Ì£¬CPU ¿ÉÒÔ¡°ÏÐÖá±£¬Òâ¼´²Ù×÷ϵͳûÓе÷¶ÈÖ´ÐÐ Èκνø³Ì;²Ù×÷ϵͳ¶Ô½ø³ÌµÄµ÷¶ÈÎÞ¹æÂÉ£¬¿É¿´×÷ÊÇËæ»úµ÷¶È¡£
(3) ´óѧ¿Î±í¹ÜÀí(CourseSchedule):¿´Ò»ÏÂÄã×Ô¼ºµÄ¿Î±í£¬Ã¿Ò»ÉÏÎç 10:00-12:00 ºÍÿÖÜÈýÉÏÎç 8:00-10:00 ÔÚÕýÐÄÂ¥ 42 ½ÌÊÒÉÏ¡°Èí¼þ¹¹Ô족¿Î
ʱ¼äÖá
ͬһÑÕÉ«µÄ¾ØÐαíʾͬһ¸ö½ø³Ì
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
³Ì¡£¿Î³ÌÐèÒªÌض¨µÄ½ÌÊÒºÍÌض¨µÄ½Ìʦ¡£ÔÚ±¾Ó¦ÓÃÖУ¬ÎÒÃǶÔʵ¼ÊµÄ¿Î ±í½øÐмò»¯:Õë¶Ôij¸ö°à¼¶£¬¼ÙÉèÆä¸÷ÖÜµÄ¿Î±í¶¼ÊÇÍêÈ«Ò»ÑùµÄ(Òâ¼´ ͬÑùµÄ¿Î³Ì°²ÅŽ«ÒÔ¡°ÖÜ¡±Îªµ¥Î»½øÐÐÖÜÆÚÐÔµÄÖظ´£¬Ö±µ½Ñ§ÆÚ½áÊø); Ò»ÃſγÌÿÖÜ¿ÉÒÔ³öÏÖ 1 ´Î£¬Ò²¿ÉÒÔ°²ÅŶà´Î(ÀýÈçÿÖÜÒ»ºÍÖÜÈýµÄ¡°Èí ¼þ¹¹Ôì¿Î¡±)ÇÒÓÉͬһλ½Ìʦ³Ðµ£²¢ÔÚͬÑùµÄ½ÌÊÒ½øÐÐ;ÔÊÐí¿Î±íÖÐÓÐ¿Õ °×ʱ¼ä¶Î(δ°²ÅÅÈκογÌ);¿¼Âǵ½²»Í¬Ñ§ÉúµÄÑ¡¿ÎÇé¿ö²»Í¬£¬Í¬Ò»¸ö ʱ¼ä¶ÎÄÚ¿ÉÒÔ°²ÅŲ»Í¬µÄ¿Î³Ì(ÀýÈçÖÜÒ»ÉÏÎç 3-4 ½ÚµÄ¼ÆËã·½·¨ºÍÈí¼þ ¹¹Ôì);һλ½ÌʦҲ¿ÉÒԳе£¿Î±íÖеĶàÃſγ̡£
3.2
(Ϊ¼ò»¯Æð¼û£¬ÎÞÐ迼ÂÇͼÖи÷¿Î³ÌºóÃæ±ê×¢µÄÆðÖÁÖÜ´Î)
ÃæÏò¿É¸´ÓÃÐԺͿÉά»¤Ð﵀ ADT Éè¼Æ:IntervalSet
¿¼ÂÇÉϽڸø³öµÄÈý¸öÓ¦Óã¬ÆäÖж¼°üº¬Á˾ßÓв»Í¬ÌØÕ÷µÄ¡°Ê±¼ä¶Î¼¯ºÏ¡±¶Ô Ïó£¬ÎªÁËÌá¸ßÈí¼þ¹¹ÔìµÄ¿É¸´ÓÃÐԺͿÉά»¤ÐÔ£¬¿ÉΪÆäÉè¼ÆºÍ¹¹ÔìÒ»Ì×ͳһµÄ ADT¡£
3.2.1 IntervalSet
ÒýÈë IntervalSet
ÔÚ¸ÃÀý×ÓÖУ¬±êÇ©ÊǼòµ¥µÄ×Ö·û´®(¡°A¡±¡¢¡°B¡±¡¢¡°C¡±)£¬µ«Êµ¼ÊÓ¦ÓÃÖбêÇ©¿ÉÒÔÊÇ ÈκΠimmutable ÀàÐ굀 ADT£¬Ò²¾ÍÊÇ IntervalSet
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
ÀýÈçÉϽÚÓ¦Óà 1 ÖеıêÇ©Ó¦¸ÃÊÇ¡°Ô±¹¤¡±ADT(Employee)£¬Ó¦Óà 2 Öеıê Ç©ÊÇ¡°½ø³Ì¡±ADT(Process)£¬Ó¦Óà 3 ÖеıêÇ©ÊÇ¡°¿Î³Ì¡±ADT(Course)¡£×¢ Ò⣬һ¶¨Òª±£Ö¤ L ÊÇ immutable µÄ¡£
3.2.2 MultiIntervalSet
µ«ÊÇ£¬IntervalSet
ÈçÏÂͼËùʾ£¬±êÇ©¶ÔÏó¡°A¡±ÓëÁ½¸öʱ¼ä¶Î·¢ÉúÁªÏµ£¬¡°B¡±Ò²ÊÇÈç´Ë¡£¸Ãͼ¿É ±íʾΪ{ A=[[0,5],[20,25]], B=[[10,20],[25,30]], C=[[30,35]] }¡£
3.3 ADT µÄÉè¼ÆÓëʵÏÖ
3.3.1 IntervalSet
Ϊ½Ó¿Ú IntervalSet
l ´´½¨Ò»¸ö¿Õ¶ÔÏó:empty()
l ÔÚµ±Ç°¶ÔÏóÖвåÈëеÄʱ¼ä¶ÎºÍ±êÇ©:void insert(long start,
long end, L label)
l »ñµÃµ±Ç°¶ÔÏóÖеıêÇ©¼¯ºÏ:Set
l ´Óµ±Ç°¶ÔÏóÖÐÒƳýij¸ö±êÇ©Ëù¹ØÁªµÄʱ¼ä¶Î:boolean remove(L
label)
l ·µ»Øij¸ö±êÇ©¶ÔÓ¦µÄʱ¼ä¶ÎµÄ¿ªÊ¼Ê±¼ä:long start (L label)
l ·µ»Øij¸ö±êÇ©¶ÔÓ¦µÄʱ¼ä¶ÎµÄ½áÊøʱ¼ä:long end (L label)
l …²»ÏÞÓÚÉÏÊö·½·¨£¬Äã¿ÉÒÔ¼ÌÐø³éÏó¸÷Ó¦ÓÃËùÐèÒªµÄÆäËûÈ«¾Ö¹²ÐÔ·½·¨
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
×¢ 1:Ϊ¼ò»¯Æð¼û£¬Ê±¼äÖáÉϵÄʱ¿Ì¶¼Í³Ò»Óà long Êý¾ÝÀàÐͱíʾ¡£
×¢ 2:ÉÏÊö·½·¨ÈôÓÐÐèÒªÅ׳öµÄÒì³££¬¿É×Ô¶¨ÒåÒì³£ÀಢÔÚÉÏÊö·½·¨¶¨ÒåÖРʹÓá£
×¢ 3:½Ó¿ÚÖж¨ÒåµÄ·½·¨Ó¦µ±ÊǸà ADT ËùÓÐʵÀý¶ÔÏó¶¼Í³Ò»¾ßÓеġ°ÐÐΪ¡± (Óɸ÷·½·¨µÄ spec Ëù¹æ¶¨£¬µ«ÊµÏÖ·½Ê½¿ÉÄܲ»Í¬)¡£Èç¹ûij·½·¨¶ÔijЩʵÀý¶Ô ÏóÊÇÓмÛÖµµÄ¡¢¶ÔÆäËûʵÀý¶ÔÏóÊDz»´æÔڵġ°ÐÐΪ¡±£¬ÄÇô¾Í²»Ó¦¸Ã·ÅÔÚ½Ó¿ÚÀï¡£ µ±Äã¶ÁÍê 3.6.1 ½ÚÃèÊöµÄ¸÷Àà²îÒìÖ®ºó£¬¿ÉÄÜÐèÒª·µ»Øµ½ÕâÀïÖØÐÂÆÀ¹ÀÉÏÊö¸ø ³öµÄ¸÷¸ö·½·¨ÊÇ·ñ¶¼ÊÇ¡°Í³Ò»¾ßÓеÄÐÐΪ¡±£¬´Ó¶ø¶ÔËüÃÇ×ö³öɾ¼õ»òÔö¼Ó¡£
Çë¸ù¾ÝÄã¶ÔÓ¦ÓõÄÀí½âºÍ³éÏó£¬ÎªÉÏÊö¸÷·½·¨Éè¼Æ Spec£¬²¢¾Ý´ËÉè¼ÆÏàÓ¦µÄ ²âÊÔÓÃÀý¡£
½ø¶ø£¬Éè¼ÆÒ»¸öÀà CommonIntervalSet
3.3.2 MultiIntervalSet
Äã¿É×ÔÐоö¶¨½« MultiIntervalSet
ÔÚÆä rep ÖУ¬ÒªÇó±ØÐëʹÓà IntervalSet
MultiIntervalSet
l ´´½¨Ò»¸ö¿Õ¶ÔÏó:empty()»ò²»´øÈκβÎÊýµÄ¹¹Ô캯Êý
l ´´½¨Ò»¸ö·Ç¿Õ¶ÔÏó:¹¹Ô캯Êý MultiIntervalSet(IntervalSet
initial)£¬ÀûÓà initial Öаüº¬µÄÊý¾Ý´´½¨·Ç¿Õ¶ÔÏó
l ÔÚµ±Ç°¶ÔÏóÖвåÈëеÄʱ¼ä¶ÎºÍ±êÇ©:void insert(long start,
long end, L label)
l »ñµÃµ±Ç°¶ÔÏóÖеıêÇ©¼¯ºÏ:Set
l ´Óµ±Ç°¶ÔÏóÖÐÒƳýij¸ö±êÇ©Ëù¹ØÁªµÄËùÓÐʱ¼ä¶Î:boolean remove(L
label)
l ´Óµ±Ç°¶ÔÏóÖлñÈ¡Óëij¸ö±êÇ©Ëù¹ØÁªµÄËùÓÐʱ¼ä¶Î: IntervalSet
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
[[10,20]] }£¬ÄÇô intervals(“A”)·µ»ØµÄ½á¹ûÊÇ{ 0=[0,10],
1=[20,30] }¡£
l …²»ÏÞÓÚÉÏÊö·½·¨£¬Äã¿ÉÒÔ¼ÌÐø³éÏóÐèÒªµÄÆäËûÈ«¾Ö¹²ÐÔ·½·¨
ΪÉÏÊö¸÷·½·¨Éè¼Æ Spec£¬²¢¾Ý´ËÉè¼ÆÏàÓ¦µÄ²âÊÔÓÃÀý¡£
½ø¶ø£¬Éè¼Æ rep¡¢RF¡¢AI¡¢Safety from Rep Exposure£¬ÊµÏÖ¸÷¸ö·½·¨¡¢ checkRep()¡¢toString()£¬ÆäÖÐ toString()½«¶ÔÏóÄÚÈݱíʾΪÈËÈÝÒ×Àí½âµÄ Îı¾×Ö·û´®ÐÎʽ¡£
3.3.1 ½ÚÀïµÄÈý¸ö¡°×¢¡±£¬¶Ô MultiIntervalSet À´ËµÈÔÈ»ÓÐЧ¡£
ÎÊÌâ:¿¼ÂÇ MultiIntervalSet
3.4 ʵ¼ÊÓ¦ÓÃÖеı仯 3.4.1 Èý¸öά¶ÈÉϵIJîÒì
Õë¶Ô IntervalSet
1. ÊÇ·ñÔÊÐíʱ¼äÖáÉÏÓпհס£Èô¡°ÊÇ¡±£¬Ôòʱ¼äÖáÉÏijЩʱ¼ä¶ÎûÓиúÈκΠ±êÇ©¹ØÁª;Èô¡°·ñ¡±£¬Ôòʱ¼äÖáÉϵÄÈκÎʱ¼äµã¶¼Á¥ÊôÓÚij¸ö±êÇ©µÄʱ¼ä ¶Î¡£ÀýÈç:ÔÚÓ¦Óà 1 ÖУ¬²»ÔÊÐíÓпհ×;ÔÚÓ¦Óà 2 ºÍÓ¦Óà 3 ÖУ¬ÔÊÐíÓÐ ¿Õ°×¡£
2. ÊÇ·ñÔÊÐí²»Í¬µÄintervalÖ®¼äÓÐÖصþ¡£Èô¡°ÔÊÐí¡±£¬Ôò¶à¸öinterval ¿ÉÄÜ´æÔÚÖصþ£¬µ«¾ßÓÐÏàͬ label µÄ¶à¸ö interval Ö®¼äÈÔ²»ÔÊÐíÓÐÖØ µþ;Èô¡°²»ÔÊÐí¡±£¬ÔòÈκÎÁ½¸ö interval Ö®¼ä²»»áÓÐÈκÎÖصþ(¼´Ä³¸ö ʱ¼äµãÖ»ÄÜÊôÓÚÒ»¸öʱ¼ä¶Î)¡£ÀýÈç:ÔÚÓ¦Óà 1 ºÍÓ¦Óà 2 ÖУ¬²»ÔÊÐíÓÐÖØ µþ;ÔÚÓ¦Óà 3 ÖУ¬ÔÊÐíÓÐÖصþ¡£//Õâ¸öÐèÒªÔÚ ADT µÄ RI ºÍ checkRep() Öмì²é£¬²¢¸ù¾Ý¡°ÔÊÐí¡±»ò¡°²»ÔÊÐí¡±£¬´Ó ADT ÖÐÅÉÉú³ö²»Í¬µÄ×ÓÀàÐÍ¡£
//Ò»ÖÖÖ±¹ÛµÄÏë·¨ÊÇÔÚ ADT µÄ RI Öн«¡°ÓÐÎ޿հס±µÄÔ¼Êø¶¨Òå
³öÀ´²¢ÔÚ checkRep()ÖмÓÒÔ¼ì²é£¬µ«ÕâÊDz»ºÏÀíµÄ:¸Ã ADT ÊÇ mutable
µÄ£¬ÆäʵÀý¶ÔÏó¿É²»¶Ïµ÷Óà insert(…)ÏòÆäÖвåÈë interval£¬Ö»ÓÐ
µ½Óû§³¹µ×²åÈë½áÊøÖ®ºó²ÅÄܹ»Åжϡ°ÓÐÎ޿հס±µÄÔ¼ÊøÊÇ·ñ±»×ñÑ£¬
¶ø²»ÊÇÔÚÿ´Î insert Ö®ºó¾ùÒªÅж¨¡£Òò´Ë£¬¶Ô¸ÃÔ¼ÊøµÄÅж¨ÐèÒªÔÚ¾ß
Ìå×ÓÀàÖбí´ï:µ±²»ÔÙÔö¼ÓеÄʱ¼ä¶Îʱ£¬¼ì²éʱ¼äÖáÉÏÌض¨·¶Î§ÄÚÊÇ
·ñ´æÓпհף¬ÒÔÅжÏÆäÊÇ·ñºÏ·¨¡£
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
3. ÊÇ·ñ°üº¬ÖÜÆÚÐÔµÄʱ¼ä¶Î¡£ÖÜÆÚÐÔµÄʱ¼ä¶ÎÊÇָij¸öʱ¼ä¶Î°´Ìض¨µÄÖÜ ÆÚ³¤¶ÈÖظ´³öÏÖ£¬ÀýÈçÓ¦Óà 3 ÖÐÒÔ¡°Ò»ÖÜ¡±Îªµ¥Î»Öظ´Ä³¸ö¿Î³Ì£¬µ«Ó¦ Óà 1 ºÍÓ¦Óà 2 Öв»´æÔÚÕâÖÖÇé¿ö¡£//¿ÉÅÉÉú³ö×ÓÀàÐÍ£¬Õë¶Ôÿ¸öʱ¼ä¶Î£¬ ±êʶÆäÖظ´Óë·ñ
3.4.2 ÁùÖÖ¿ÉÄܵÄÉè¼Æ·½°¸
Èç¹û¸÷Ó¦ÓÃÔÚÉÏÊöij¸öά¶ÈÉϵÄÌØÕ÷ÖµÍêÈ«Ïàͬ£¬Ôò¿ÉÒÔ½«Õë¶Ô´¦Àí¸Ã¹²ÐÔ ÌØÕ÷ÖµµÄ²Ù×÷ÔÚÉϲãµÄʵÏÖÀàÖж¨ÒåºÍʵÏÖ£¬¿ÉʵÏÖÍêÈ«µÄ¸´Óá£Èç¹ûÔÚij¸öά ¶ÈÉϵÄÌØÕ÷È¡ÖµÍêÈ«²»Í¬£¬¾Í±ØÐëÔÚ¸÷¸öÓ¦ÓõľßÌå×ÓÀàÖзֱðʵÏÖÆä¶Ô²»Í¬ÌØ Õ÷È¡ÖµµÄ¸öÐÔ»¯²Ù×÷¡£
µ«ÊÇ£¬ÕâÈý¸öÓ¦ÓÃÔÚÈκÎÒ»¸öά¶ÈÉϵÄÌØÕ÷È¡Öµ¼È²»ÊÇÍêÈ«Ïàͬ£¬Ò²²»ÊÇÍê È«²»Í¬¡£ÈçºÎ×î´ó³Ì¶ÈÉÏʵÏÖÔÚÿ¸öά¶ÈÉϾßÓÐÏàͬÌØÕ÷µÄ¶à¸öÓ¦ÓÃÖ®¼äµÄ¹¦ÄÜ ¸´ÓÃ?
·½°¸ 1:½«ËùÓÐÌØÊâ²Ù×÷¾ù·ÅÈ붥²ãµÄ³éÏó½Ó¿Ú
½«¸÷Ó¦ÓÃÖгöÏÖµÄËùÓÐÌØÊâ²Ù×÷¶¼·ÅÈ붥²ã½Ó¿Ú IntervalSet
·½°¸ 2:½«¸÷ÌØÊâ²Ù×÷·Ö±ð·ÅÈëµ×²ãµÄÓ¦ÓÃ×ÓÀà
½«Õë¶Ô²»Í¬ÌØÕ÷È¡ÖµµÄ¾ßÌå²Ù×÷·Ö±ð·ÅÔÚÈý¸öÓ¦ÓõÄ×ÓÀàÖмÓÒÔʵÏÖ¡£ÀýÈç: ÔÚʵÏÖÅÅ°à±íµÄ×ÓÀàÖÐʵÏÖÉÏÊö insert ·½·¨£¬ÆäËûÁ½¸öÓ¦ÓõÄ×ÓÀ಻ÐèʵÏָà ·½·¨¡£¸Ã·½°¸µÄȱµãÊÇ:ijЩ·½·¨µÄ´úÂë¿ÉÄÜÊÇÖظ´µÄ¡¢·ÖÉ¢ÔÚ¶à¸öÀàÖУ¬¿Éά »¤ÐԺͿɸ´ÓÃÐԲ½«À´Ò»µ©ÃæÁٱ仯¾ÍÐèÒªÐ޸Ķദ´úÂë¡£
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
·½°¸ 3:Ϊ²»Í¬ÌØÕ÷È¡Öµ·Ö±ð¶¨Òå½Ó¿Ú²¢ÔÚ×ÓÀàÖÐʵÏÖÆäÌØÊâ²Ù×÷
Ϊÿ¸öά¶ÈÉϵIJ»Í¬ÌØÕ÷È¡Öµ·Ö±ð¶¨Ò岻ͬµÄ½Ó¿Ú£¬ÔÚ½Ó¿ÚÖж¨ÒåÌØÊâµÄ²Ù ×÷£¬¸÷Ó¦ÓõľßÌå×ÓÀà¸ù¾Ý×Ô¼ºµÄÐèÇóÀ´ÊµÏÖ²»Í¬ÌØÕ÷µÄ½Ó¿Ú¡£ÒÔ¡°ÊÇ·ñÔÊÐíÖØ µþ¡±Î¬¶ÈΪÀý:
ÔÚÕâÖÖ·½°¸Ï£¬Ã¿¸öÓ¦ÓõľßÌå×ÓÀà¿ÉÒÔ°´ÒÔÏ·½Ê½¼ÓÒÔʵÏÖ:
class DutyIntervalSet
extends CommonIntervalSet
NoBlankIntervalSet
NonPeriodicIntervalSet
ÄÜÔòͨ¹ý override Èý¸ö½Ó¿ÚÖеķ½·¨À´ÊµÏÖ¡£
ÕâÖÖ·½°¸Óë·½°¸ 2 ÓÐͬÑùµÄȱÏÝ:ijЩ¾Ö²¿¹²ÐԵIJÙ×÷ÈÔÈ»ÐèÒªÔÚ¶à¸ö×Ó
ÀàÖзֱð override¡¢·Ö±ðʵÏÖ¡£
·½°¸ 4:¶¨Òå½Ó¿Ú²¢ÊµÏÖ¾ßÌåÀ࣬ͨ¹ý¼Ì³ÐÊ÷ʵÏÖ¸÷Ó¦ÓÃÔÚ¶àά¶ÈÉϵIJ» ͬÌØÕ÷È¡ÖµµÄ×éºÏ
ÔÚ·½°¸ 3 »ù´¡ÉÏ£¬³ýÁËΪÿ¸öά¶ÈÉϵÄÿ¸öÌØÕ÷È¡Öµ¶¨ÒåÏàÓ¦µÄ½Ó¿Ú£¬Áí ÍâΪÿ¸ö½Ó¿Ú·Ö±ð¹¹ÔìÒ»¸öʵÏÖÀ࣬¸ÃÀàÒ»·½Ãæ¼Ì³Ð CommonIntervalSet ÖÐ µÄÈ«¾Ö¹²ÐÔ²Ù×÷£¬ÁíÒ»·½ÃæÔÚ¸ÃÀàÖÐÍê³É¶Ô¾Ö²¿¹²ÐÔ²Ù×÷µÄ´úÂë¡£ÀýÈçÕë¶ÔÉÏ ±íÖÐµÄ NonOverlapIntervalSet
ÌØÕ÷È¡Öµ
½Ó¿Ú
½Ó¿ÚÖеķ½·¨
ÊÇ
OverlapIntervalSet
void insert(…) //ÎÞÅ׳öÒì³£
·ñ
NonOverlapIntervalSet
void insert(…) throws
xxxException
public class NonOverlapIntervalSetImpl
implements NonOverlapIntervalSet
@Override
public void insert(long start, long end, L label)
throws IntervalConflictException{ //ÔÚÕâÀïʵÏÖ¶Ô¡°²»ÔÊÐí´æÔÚÖصþ¡±µÄ¼ì²é²¢¾ö¶¨ÊÇ·ñÅ׳öÒì³£
} }
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
µ«ÊÇ£¬¸Ã·½°¸´æÔÚµÄÎÊÌâÊÇ¡°×éºÏ±¬Õ¨¡±¡£ÉÏÃæÕâ¸öÀý×ÓÖ»ÊÇʵÏÖÁË¡°ÊÇ·ñ ¿ÉÖصþ¡±Õâ¸öά¶ÈÉϵġ°²»¿ÉÖصþ¡±ÌØÕ÷£¬Èç¹ûÔÙ¿¼ÂÇÁíÒ»¸öά¶È¡°ÊÇ·ñ¿É¿Õ °×¡±µÄ¡°²»ÔÊÐí¿Õ°×¡±ÌØÕ÷£¬¾ÍÐèÒª¼ÌÐø¶¨ÒåÒ»¸öеÄÀ࣬¼Ì³ÐÉÏÃæÕâ¸öÀ࣬ ²¢½øÒ»²½ÊµÏÖ¡°²»ÔÊÐí¿Õ°×¡±µÄÌØÕ÷:
public class NoBlankAndNonOverlapIntervalSetImpl
implements NoBlankIntervalSet
private long start, end;
//Ôö¼Ó rep£¬±íʾÔÚ[start, end]·¶Î§ÄÚ²»Ó¦´æÔÚ¿Õ°×ʱ¼ä¶Î @Override //·½·¨ÔÚ NoBlankIntervalSet ½Ó¿ÚÖж¨Òå
public void checkNoBlank() {…} //Ôڴ˼ì²éÊÇ·ñÓпհ×
}
Èç¹û¼ÌÐø¿¼ÂǵÚÈý¸öά¶ÈÉϵÄÌØÕ÷£¬¾ÍÐèÒªÔÚÉÏÊö NoBlankAndNonOver lapIntervalSetImpl »ù´¡ÉϼÌÐøÀ©Õ¹¡£½«¸÷¸öά¶ÈµÄ¸öÐÔ»¯Öð²½×éºÏ½øÈ¥Ö® ºó£¬¼´¿ÉµÃµ½·ûºÏ¸÷Ó¦ÓÃÌØÕ÷µÄ¾ßÌå×ÓÀà¡£
×îÖÕ£¬¶à¸öά¶ÈÉϵĶàÖÖÌØÕ÷È¡ÖµµÄ²»Í¬×éºÏ£¬½«ÐγÉÅÓ´óµÄ¼Ì³ÐÊ÷£¬Õâ
½«¸øÈí¼þϵͳµÄά»¤´úÂ뼫´óÀ§ÄÑ¡£
·½°¸ 5:CRP£¬Í¨¹ý½Ó¿Ú×éºÏʵÏÖ¾Ö²¿¹²ÐÔÌØÕ÷µÄ¸´ÓÃ
Õë¶Ô·½°¸ 3£¬Í¨¹ý delegation »úÖƽøÐиÄÔ졣ÿ¸öά¶È·Ö±ð¶¨Òå×Ô¼ºµÄ½Ó ¿Ú£¬Õë¶Ôÿ¸öά¶ÈµÄ²»Í¬ÌØÕ÷È¡Öµ£¬·Ö±ðʵÏÖÕë¶Ô¸Ãά¶È½Ó¿ÚµÄ²»Í¬ÊµÏÖÀ࣬ ʵÏÖÆäÌØÊâ²Ù×÷Âß¼¡£
½ø¶ø£¬Í¨¹ý½Ó¿Ú×éºÏ£¬½«¸÷ÖÖ¾Ö²¿¹²ÐÔÐÐΪ¸´ºÏÔÚÒ»Æð£¬ÐγÉÂú×ãÿ¸öÓ¦ ÓÃÒªÇóµÄÌØÊâ½Ó¿Ú(°üº¬Á˸ÃÓ¦ÓÃÄÚµÄÈ«²¿ÌØÊ⹦ÄÜ)£¬´Ó¶ø¸ÃÓ¦ÓÃ×ÓÀà¿ÉÖ±½Ó ʵÏÖ¸Ã×éºÏ½Ó¿Ú¡£
ÔÚÓ¦ÓÃ×ÓÀàÄÚ£¬²»ÊÇÖ±½ÓʵÏÖÿ¸öÌØÊâ²Ù×÷£¬¶øÊÇͨ¹ý delegation µ½Íⲿÿ ¸öά¶ÈÉϵĸ÷¾ßÌåʵÏÖÀàµÄÏàÓ¦ÌØÊâ²Ù×÷Âß¼¡£
public interface NonOverlapIntervalSet {…} public interface NoBlankIntervalSet{…} public interface NonPeriodicIntervalSet{…} …
public class NonOverlapIntervalSetImpl
implements NonOverlapIntervalSet
public class NoBlankIntervalSetImpl
implements NoBlankIntervalSet
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
public class NonPeriodicIntervalSetImpl
implements NonPeriodicIntervalSet
public interface IDutyIntervalSet extends NonOverlapIntervalSet,
NoBlankIntervalSet,
NonPeriodicIntervalSet { }
class DutyIntervalSet extends CommonIntervalSet
implements IDutyIntervalSet {
private NonOverlapIntervalSetImpl nois;
private NoBlankIntervalSetImpl nbis;
private NonPeriodicIntervalSetImpl npis;
public DutyIntervalSet(NonOverlapIntervalSet nois,
NoBlankIntervalSet nbis,
NonPeriodicIntervalSet npis) { …//ÉèÖà delegation ¹Øϵ
}
@Override
public void checkNoBlank() {.. //Ôڴ˼ì²éÊÇ·ñÓпհ×
nbis.checkNoBlank();
}
@Override
public void insert(long start, long end, L label)
throws IntervalConflictException{ //Ôڴ˼ì²é¡°²»ÔÊÐí´æÔÚÖصþ¡±¼ì²é²¢¾ö¶¨ÊÇ·ñ²åÈë¡¢ÊÇ·ñÅ׳öÒì³£
nois.insert(…);
}
… }
·½°¸ 4 ºÍ·½°¸ 5 ÌåÏÖÁËÔÚ¸´ÔÓ³¡¾°ÏÂʹÓà inheritance ºÍ delegation ʵÏÖ¸´Óà µÄ²îÒì¡£
·½°¸ 6:ʹÓà decorator Éè¼Æģʽ
½« CommonIntervalSet ¿´×÷ÊÇÔʼµÄ¡¢Î´±»×°ÊεĶÔÏ󣬽«ÕâÈý¸öά¶È¿´
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
×÷ÊÇÈýÖÖ¡°×°ÊΡ±(ÿ¸öά¶ÈµÄ²»Í¬ÌØÕ÷È¡Öµ¿ÉÒÔ²úÉú²»Í¬µÄ¡°×°ÊΡ±Ð§¹û)¡£ Çë²ÎÕÕ½²ÒåÉϹØÓÚ¸ÃÉè¼ÆģʽµÄ˵Ã÷£¬Éè¼ÆÏàÓ¦µÄ×ÓÀàÐͼ̳йØϵÊ÷£¬È»ºóÔÚ ¾ßÌåÓ¦ÓÃÖÐͨ¹ýΪһ¸ö CommonIntervalSet ¶ÔÏóÖð²ã×°ÊÎÈý¸ö²»Í¬ÌØÕ÷£¬¼´ ¿ÉʵÏÖÓ¦ÓÃËùÐèµÄ×éºÏÌØÕ÷¡£
ÔÚÄãµÄʵÑéÖУ¬Çë¸ù¾ÝÄãµÄÆ«ºÃÑ¡ÔñÉÏÊöijÖÖ·½°¸¼ÓÒÔÉè¼ÆºÍʵÏÖ£¬»òÕß
²ÉÓÃÄãÈÏΪºÏÀíµÄÉè¼Æ·½°¸¡£ÄãÒ²¿ÉÒÔʵÏÖ¶àÖÖ·½°¸£¬²¢¶ÔËüÃǵĿÉά»¤ÐÔ¡¢
¿É¸´ÓÃÐÔµÈ×öЩ¶Ô±È·ÖÎö¡£
3.4.3 ÃæÏò¸÷Ó¦ÓÃµÄ ADT ×ÓÀàÐÍ
ΪÁËÖ§³ÖÈý¸öÓ¦Óã¬ÄãÐèÒª»ùÓÚÉÏһС½ÚµÄij¸öÉè¼Æ·½°¸·Ö±ð¹¹Ôì/ÅÉÉú³ö ¸ü¾ßÌåµÄ¡¢ÃæÏòÓ¦ÓÃµÄ ADT ×ÓÀàÐÍ£¬Ã¿¸ö×ÓÀàÐͿɸù¾ÝÓ¦ÓÃÐèÒªÀ´Ñ¡ÔñÊÇ»ùÓÚ IntervalSet
l DutyIntervalSet:´ú±íÒ»¸öÅÅ°à±í;
l ProcessIntervalSet:´ú±íÒ»¸ö²Ù×÷ϵͳ¶Ô½ø³ÌµÄµ÷¶È¼Ç¼;
l CourseIntervalSet:´ú±íij¸ö°à¼¶µÄÌض¨¿Î±í¡£
Õë¶Ô´Ó IntervalSet
ADT ×ÓÀàÐÍ£¬×«Ð´ AF¡¢RI¡¢Safety from rep exposure£¬ÒÔ¼°Ã¿¸ö·½·¨µÄ spec¡£Îª ËüÃÇÉè¼ÆºÍ±àд JUnit ²âÊÔÓÃÀý£¬²¢×«Ð´ testing strategy¡£
¹éÄÉÆðÀ´£¬×îÖÕÉè¼ÆµÃµ½µÄ ADT ½á¹¹ÀàËÆÓÚÏÂͼËùʾ:
3.5 ÃæÏò¸´ÓõÄÉè¼Æ:L
IntervalSet
IntervalSet
<
CommonIntervalSet
<
Ñ¡Ôñ·½°¸ 1-6Ö®Ò»¿ªÕ¹Éè¼Æ
<
MultiIntervalSet
ÀàËƵĽṹ
³éÏó½Ó¿Ú
ͨÓõÄʵÏÖ
²¿·ÖͨÓõÄʵÏÖ
ÍêÈ«¸öÐÔ»¯µÄʵÏÖ
DutyIntervalSet
ProcessIntervalSet
CourseIntervalSet
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
¼ÆµÄÈκΠimmutable µÄÀà¡£
¶ÔÈý¸öÓ¦ÓÃÀ´Ëµ£¬Æä L ·Ö±ðӦΪ¡°Ô±¹¤¡±(Employee)¡¢¡°½ø³Ì¡±(Process)¡¢
¡°¿Î³Ì¡±(Course)£¬ËùÐè¹Ø×¢µÄÊôÐÔ·Ö±ðΪ:
l Employee:ÐÕÃû¡¢Ö°Îñ¡¢ÊÖ»úºÅÂë
l Process:½ø³ÌID¡¢½ø³ÌÃû³Æ¡¢×î¶ÌÖ´ÐÐʱ¼ä¡¢×ִÐÐʱ¼ä l Course:¿Î³ÌID¡¢¿Î³ÌÃû³Æ¡¢½ÌʦÃû×Ö¡¢µØµã
·Ö±ðʵÏÖÕâЩ ADT¡£
3.6
¿É¸´Óà API Éè¼ÆÓ뿪·¢
Éè¼ÆºÍʵÏÖÒÔϸ÷¸ö API£¬ËüÃÇ¿ÉÒÔ°üº¬ÔÚ IntervalSet
1. ¼ÆËãÁ½¸ö MultiIntervalSet ¶ÔÏóµÄÏàËƶÈ:
double Similarity(MultiIntervalSet
¾ßÌå¼ÆËã·½·¨:°´ÕÕʱ¼äÖá´ÓÔçµ½ÍíµÄ´ÎÐò£¬Õë¶Ôͬһ¸öʱ¼ä¶ÎÄÚÁ½¸ö¶ÔÏó ÀïµÄ interval£¬ÈôËüÃDZê×¢µÄ label µÈ¼Û£¬Ôò¶þÕßÏàËƶÈΪ 1£¬·ñÔòΪ 0;Èô ͬһʱ¼ä¶ÎÄÚÖ»ÓÐÒ»¸ö¶ÔÏóÓÐ interval »ò¶þÕ߶¼Ã»ÓУ¬ÔòÏàËƶÈΪ 0¡£½«¸÷ interval µÄÏàËƶÈÓë interval µÄ³¤¶ÈÏà³ËºóÇóºÍ£¬³ýÒÔ×ܳ¤¶È£¬¼´µÃµ½¶þÕß µÄÕûÌåÏàËƶȡ£
Õë¶ÔÉÏͼÖеÄÁ½¸ö¶ÔÏó:
{ A = [[0,5],[20,25]], B = [[10,20],[25,30]] }
{ A = [[20,35]], B = [[10,20]], C = [[0,5]] }
ËüÃǵÄÏàËƶȼÆËãÈçÏÂ:
( 5¡Á0 + 5¡Á0 + 10¡Á1 + 5¡Á1 + 5¡Á0 + 5¡Á0 ) ¡Â ( 35 – 0 ) = 15 / 35 ¡Ö 0.42857
2. ·¢ÏÖÒ»¸ö IntervalSet
double calcConflictRatio(IntervalSet
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
ËùνµÄ¡°³åÍ»¡±£¬ÊÇָͬһ¸öʱ¼ä¶ÎÄÚ°²ÅÅÁËÁ½¸ö²»Í¬µÄ interval ¶ÔÏó¡£Óà ·¢Éú³åÍ»µÄʱ¼ä¶Î×ܳ¤¶È³ýÓÚ×ܳ¤¶È£¬µÃµ½³åÍ»±ÈÀý£¬ÊÇÒ»¸ö[0,1]Ö®¼äµÄÖµ¡£
3. ¼ÆËãÒ»¸ö IntervalSet
double calcFreeTimeRatio(IntervalSet
double calcFreeTimeRatio(MultiIntervalSet
¼ä¶Î×ܳ¤¶È³ýÓÚ×ܳ¤¶È£¬µÃµ½¿ÕÏбÈÀý£¬ÊÇÒ»¸ö[0,1]Ö®¼äµÄÖµ¡£ 3.7 Ó¦ÓÃÉè¼ÆÓëʵÏÖ
ÀûÓÃÇ°ÃæËù¿ª·¢µÄ ADT£¬ÎªÈý¸öÓ¦Óó¡¾°·Ö±ð¿ª·¢³ÌÐò£¬¿ÉÒÔʵÏÖΪ GUI ³Ì Ðò£¬Ò²¿ÉÒÔÊÇÃüÁîÐгÌÐò£¬Èý¸öÓ¦ÓõÄÖ÷³ÌÐò·Ö±ðʵÏÖΪ:
l DutyRosterApp.java
l ProcessScheduleApp.java
l CourseScheduleApp.java¡£
×¢ 1:³ýÁËÏÂÃæ¸÷½Ú¸ø³öµÄ¹¦ÄÜ£¬»¹¿É¸ù¾Ý×Ô¼ººÏÀíµÄÉè¼Æ£¬ÔÚÓ¦ÓÃÖÐʵÏÖ
ÆäËûÄãÈÏΪÓмÛÖµµÄ¹¦ÄÜ(µ«²»²ÎÓëÆÀ·Ö)¡£
×¢ 2:ÓÐÈË»áÈÏΪÈý¸öÓ¦ÓõĿª·¢¹¤×÷Á¿Ì«´ó£¬ÇÒÕâЩӦÓõŦÄܷdz£ÏàÏñ£¬
ºÎ±ØÖظ´Õâô¶à´Î¡£Õâ¿ÉÒÔÓÃÀ´¼ì²éÄãµÄ ADT Éè¼ÆÊÇ·ñÓÐ×ã¹»µÄ¿É¸´ÓÃÐÔºÍÊÊ Ó¦ÐÔ£¬Èç¹û ADT Éè¼ÆµÃºÃ£¬Ó¦Óÿª·¢µÄ¹¤×÷Á¿»á´ó·ù¶È¼õÉÙ¡£
3.7.1 ÅÅ°à¹ÜÀíϵͳ
Õë¶ÔÅÅ°à¹ÜÀíϵͳ£¬ËùÐèÍê³ÉµÄ¹¦ÄÜΪ:
Step 1 É趨ÅŰ࿪ʼÈÕÆÚ¡¢½áÊøÈÕÆÚ£¬¾ßÌåµ½ÄêÔÂÈÕ¼´¿É¡£
Step 2 Ôö¼ÓÒ»×éÔ±¹¤£¬°üÀ¨ËûÃǸ÷×ÔµÄÃû×Ö¡¢Ö°Îñ¡¢ÊÖ»úºÅÂ룬²¢¿ÉËæʱɾ
³ýijЩԱ¹¤¡£Èç¹ûij¸öÔ±¹¤ÒѾ±»±àÅŽøÅÅ°à±í£¬ÄÇôËû²»Äܱ»É¾³ý£¬±ØÐ뽫Æä ÅÅ°àÐÅϢɾµôÖ®ºó²ÅÄÜɾ³ý¸ÃÔ±¹¤¡£Ô±¹¤ÐÅÏ¢Ò»µ©É趨ÔòÎÞ·¨Ð޸ġ£
Step 3 ¿ÉÊÖ¹¤Ñ¡Ôñij¸öÔ±¹¤¡¢Ä³¸öʱ¼ä¶Î(ÒÔ¡°ÈÕ¡±Îªµ¥Î»£¬×îС 1 Ì죬¿É ÒÔÊǶàÌì)£¬ÏòÅÅ°à±íÔö¼ÓÒ»ÌõÅÅ°à¼Ç¼£¬¸Ã²½Öè¿ÉÖظ´Ö´Ðжà´Î¡£Ôڸùý³ÌÖУ¬ Óû§¿ÉËæʱ¼ì²éµ±Ç°ÅÅ°àÊÇ·ñÒÑÂú(¼´ËùÓÐʱ¼ä¶Î¶¼Òѱ»°²ÅÅÁËÌض¨Ô±¹¤Öµ°à)¡¢ ÈôδÂú£¬Ôòչʾ¸øÓû§ÄÄЩʱ¼ä¶Îδ°²ÅÅ¡¢Î´°²ÅŵÄʱ¼ä¶ÎÕ¼×Üʱ¼ä¶ÎµÄ±ÈÀý¡£
Step 4 ³ýÁËÉÏÒ»²½ÖèÖÐÊÖ¹¤°²ÅÅ£¬Ò²¿É²ÉÓÃ×Ô¶¯±àÅŵķ½·¨£¬Ëæ»úÉú³ÉÅÅ°à ±í¡£
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
Step 5 ¿ÉÊÓ»¯Õ¹Ê¾ÈÎÒâʱ¿ÌµÄÅÅ°à±í¡£¿ÉÊÓ»¯ÒªÖ±¹ÛÃ÷ÁË£¬¿É×ÔÐÐÉè¼Æ¡£ 3.7.2 ²Ù×÷ϵͳµÄ½ø³Ìµ÷¶È¹ÜÀíϵͳ
Õë¶Ô²Ù×÷ϵͳµÄ½ø³Ìµ÷¶È¹ÜÀíϵͳ£¬ËùÐèÍê³ÉµÄ¹¦ÄÜΪ:
Step 1 Ôö¼ÓÒ»×é½ø³Ì£¬ÊäÈëÿ¸ö½ø³ÌµÄ ID¡¢Ãû³Æ¡¢×î¶ÌÖ´ÐÐʱ¼ä¡¢×ִ ÐÐʱ¼ä;½ø³ÌÒ»µ©É趨ÎÞ·¨ÔÙÐÞ¸ÄÆäÐÅÏ¢¡£
Step 2 µ±Ç°Ê±¿Ì(É趨Ϊ 0)Æô¶¯Ä£Äâµ÷¶È£¬Ëæ»úÑ¡Ôñij¸öÉÐδִÐнáÊøµÄ ½ø³ÌÔÚ CPU ÉÏÖ´ÐÐ(Ö´Ðйý³ÌÖÐÆäËû½ø³Ì²»Äܱ»Ö´ÐÐ)£¬²¢Ôڸýø³Ì×î´óʱ¼äÖ® Ç°µÄÈÎÒâʱ¿ÌÍ£Ö¹Ö´ÐУ¬Èç¹û±¾´Î¼°Æä֮ǰµÄÀÛ»ýÖ´ÐÐʱ¼äÒÑÂäµ½[×î¶ÌÖ´ÐÐʱ ¼ä£¬×ִÐÐʱ¼ä]µÄÇø¼äÄÚ£¬Ôò¸Ã½ø³Ì±»É趨Ϊ¡°Ö´ÐнáÊø¡±¡£Öظ´ÉÏÊö¹ý³Ì£¬ Ö±µ½ËùÓнø³Ì¶¼´ïµ½¡°Ö´ÐнáÊø¡±×´Ì¬¡£ÔÚÿ´ÎÑ¡Ôñʱ£¬Ò²¿É¡°²»Ö´ÐÐÈκνø³Ì¡±£¬ ²¢ÔÚºóÐøËæ»úÑ¡¶¨µÄʱ¼äµãÔٴνøÐнø³ÌÑ¡Ôñ¡£
Step 3 ÉÏÒ»²½ÖèÊÇ¡°Ëæ»úÑ¡Ôñ½ø³Ì¡±µÄÄ£Äâ²ßÂÔ£¬»¹¿ÉÒÔʵÏÖ¡°×î¶Ì½ø³ÌÓÅ ÏÈ¡±µÄÄ£Äâ²ßÂÔ:ÿ´ÎÑ¡Ôñ½ø³ÌµÄʱºò£¬ÓÅÏÈÑ¡Ôñ¾àÀëÆä×î´óÖ´ÐÐʱ¼ä²î¾à×îС µÄ½ø³Ì¡£
Step 4 ¿ÉÊÓ»¯Õ¹Ê¾µ±Ç°Ê±¿Ì֮ǰµÄ½ø³Ìµ÷¶È½á¹û£¬ÒÔ¼°µ±Ç°Ê±¿ÌÕýÔÚÖ´ÐÐ µÄ½ø³Ì¡£¿ÉÊÓ»¯µÄÐÎʽҪֱ¹ÛÃ÷ÁË£¬¿É×ÔÐÐÉè¼Æ¡£
3.7.3 ¿Î±í¹ÜÀíϵͳ
Õë¶Ô¿Î±í¹ÜÀíϵͳ£¬ËùÐèÍê³ÉµÄ¹¦ÄÜΪ:
Step 1 É趨ѧÆÚ¿ªÊ¼ÈÕÆÚ(ÄêÔÂÈÕ)ºÍ×ÜÖÜÊý(ÀýÈç 18);
Step 2 Ôö¼ÓÒ»×é¿Î³Ì£¬Ã¿Ãſγ̵ÄÐÅÏ¢°üÀ¨:¿Î³Ì ID¡¢¿Î³ÌÃû³Æ¡¢½ÌʦÃû
×Ö¡¢µØµã¡¢ÖÜѧʱÊý(żÊý);
Step 3 ÊÖ¹¤Ñ¡Ôñij¸ö¿Î³Ì¡¢ÉÏ¿Îʱ¼ä(Ö»ÄÜÊÇ 8-10 ʱ¡¢10-12 ʱ¡¢13-15 ʱ¡¢
15-17 ʱ¡¢19-21 ʱ)£¬ÎªÆä°²ÅÅÒ»´Î¿Î£¬Ã¿´Î¿ÎµÄʱ¼ä³¤¶ÈΪ 2 Сʱ;¿ÉÖظ´°² ÅÅ£¬Ö±µ½´ïµ½ÖÜѧʱÊýĿʱ¸Ã¿Î³Ì²»ÄÜÔÙ°²ÅÅ;
Step 4 Éϲ½Öè¹ý³ÌÖУ¬Ëæʱ¿É²é¿´ÄÄЩ¿Î³Ìû°²ÅÅ¡¢µ±Ç°Ã¿ÖܵĿÕÏÐʱ¼ä±È Àý¡¢Öظ´Ê±¼ä±ÈÀý;
Step 5 ÒòΪ¿Î³ÌÊÇÖÜÆÚÐԵģ¬Óû§¿É²é¿´±¾Ñ§ÆÚÄÚÈÎÒâÒ»ÌìµÄ¿Î±í½á¹û¡£ 3.8 »ùÓÚÓï·¨µÄÊý¾Ý¶ÁÈë
Õë¶Ô 3.10 ½ÚÖпª·¢µÄ¡°Öµ°à±í¹ÜÀí¡±Ó¦Óã¬ÎªÆäÀ©Õ¹Ò»¸ö¹¦ÄÜ:´ÓÒ»¸öÍⲿ Îı¾Îļþ¶ÁÈëÊý¾Ý²¢Ê¹ÓÃÕýÔò±í´ïʽ parser ¶ÔÆä½øÐнâÎö£¬´ÓÖгéÈ¡ÐÅÏ¢£¬¹¹Ôì
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
Öµ°à±í¶ÔÏó¡£ÊäÈëÎļþµÄÓ﷨ʾÀýÈçÏÂËùʾ£¬Äã¿É´ÓÒÔϵØÖ·ÏÂÔØʾÀýÎļþÓÃÓÚ ÄãµÄ³ÌÐò²âÊÔ:
https://github.com/rainywang/Spring2021_HITCS_SC_Lab3
ÔÚÒÔÏÂʾÀýÖУ¬²»´øÓÐÏ»®ÏßµÄÎÄ×Ö²¿·ÖΪ¹Ì¶¨ËµÃ÷²¿·Ö£¬´øÓÐÏ»®ÏßµÄÎÄ ×Ö²¿·ÖΪ¿É±ä»¯ÐÅÏ¢¡£¡°//¡±ºóÐøÎÄ×ÖÊǽâÊÍ˵Ã÷£¬²¢·ÇÓï·¨µÄ¹¹³É²¿·Ö¡£
ÎļþÀïÃèÊöµÄ Employee¡¢Period¡¢Roster µÄ´ÎÐòÊDz»È·¶¨µÄ£¬Î¥·´¸Ã´ÎÐò²» Äܱ»¿´×÷·Ç·¨¡£
ÔÚ¶ÁÈ¡Îļþ¹ý³ÌÖУ¬Èô·¢ÏÖÓÐÎ¥·´±¾ÀýÖнâÊÍ˵Ã÷²¿·Ö¸ø³öµÄ¹æÔò£¬Ôò¸ÃÎÄ ¼þ²»·ûºÏÓï·¨£¬Ðè½áÊø¶ÁÈ¡²¢ÌáʾÓû§Ñ¡ÔñÆäËûºÏ·¨µÄÎļþ¡£
ÁíÍ⣬ÇëºöÂÔÎļþÖеÄËùÓÐËõ½ø£¬Ëü²¢·ÇÓï·¨µÄ×é³É²¿·Ö¡£
Employee{ //¶à¸öÔ±¹¤ÐÅÏ¢
ZhangSan{Manger,139-0451-0000} //{}Ç°ÊÇÔ±¹¤ÐÕÃû£¬´óСд×Öĸ¹¹³É
//²»Í¬µÄÐÐÄÚµÄÔ±¹¤Ãû×ÖÊÇΨһµÄ£¬²»ÄÜÖظ´ LiSi{Secretary,151-0101-0000} //{}ÄÚµÚÒ»¸ö·ÖÁ¿ÊÇÖ°Îñ£¬´óСд×ÖĸºÍ¿Õ¸ñ
WangWu{Associate Dean,177-2021-0301} //{}ÄÚµÚ¶þ¸ö·ÖÁ¿ÊÇÖйú¾³ÄںϷ¨µÄÊÖ»úºÅÂë
//¹² 11 룬·ÖΪÈý¶Î(3-4-4)£¬Óá°-¡±ÏàÁ¬
}
Period{2021-01-10,2021-03-06} //±íʾÅÅ°àµÄ¿ªÊ¼ÈÕÆںͽáÊøÈÕÆÚ Roster{ //±íʾÅÅ°à¼Æ»®
ZhangSan{2021-01-10,2021-01-31} //·Ö±ðΪÐÕÃû¡¢¿ªÊ¼ÈÕÆÚ¡¢½áÊøÈÕÆÚ LiSi{2021-02-01,2021-02-28} //ÉÏÊöËùÓÐÈÕÆڵĸñʽΪ yyyy-MM-dd WangWu{2021-03-01,2021-03-10}
//³öÏÖÔÚ Roster ÄÚµÄÔ±¹¤£¬±ØÐëÔÚ Employee ÖÐÒÑÓж¨Ò壬·ñÔò²»ºÏ·¨ }
3.9 еı仯
Ç°Ã濪·¢³öµÄ¸÷Ó¦Óã¬ÃæÁÙ×ÅÒÔϵļ¸¸ö¹¦Äܱ仯¡£Ç뿼²éÔÓеÄÉè¼Æ£¬ÊÇ ·ñÄÜÒÔ½ÏСµÄ´ú¼ÛÊÊÓ¦ÕâЩ±ä»¯¡£ÐÞ¸ÄÔÓÐÉè¼Æ£¬Ê¹Ö®Äܹ»Ó¦¶ÔÕâЩ±ä»¯¡£ÔÚÐÞ ¸Ä֮ǰ£¬ÇëÈ·±£Äã֮ǰµÄ¿ª·¢ÒѾ commit µ½ Git ²Ö¿â£¬È»ºó´´½¨Ð·ÖÖ§¡°change¡±£¬ Ôڸ÷ÖÖ§ÉÏÍê³É±¾½ÚÈÎÎñ¡£
l ÅÅ°àÓ¦ÓÃ:¿ÉÒÔ³öÏÖÒ»¸öÔ±¹¤±»°²ÅŶà¶ÎÖµ°àµÄÇé¿ö£¬ÀýÈçÕÅÈýµÄÖµ°à ÈÕÆÚΪ(2021-01-01, 2021-01-10), (2021-02-01, 2021-02-06);
l ¿Î±íÓ¦ÓÃ:²»¹ÜѧÉúÑ¡¿Î×´¿öÈçºÎ£¬²»Äܹ»³öÏÖÁ½ÃÅ¿ÎÅÅÔÚͬһʱ¼äµÄ Çé¿ö(¼´¡°ÎÞÖصþ¡±)
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
ÔÚ¾ßÌåÐÞ¸Ä֮ǰ£¬Çë¸ù¾ÝÇ°ÃæµÄ ADT ÓëÓ¦ÓÃÉè¼Æ£¬ÏÈ´óÖ¹ÀËãÒ»ÏÂÄãµÄ³Ì ÐòÐèÒª±ä»¯¶à´ó²ÅÄÜÊÊÓ¦ÕâЩ±ä»¯¡£ÐÞ¸ÄÖ®ºó£¬ÔÙÏà¶Ô¾«È·µÄ¶ÈÁ¿Ò»ÏÂÄãÔÚ¸Ã½Ú Ö®Ç°Ëù×öµÄ ADT Éè¼ÆÒÔ¶à´óµÄ´ú¼ÛÊÊÓ¦Á˸ñíÖеÄÿһ¸ö±ä»¯?ÕâÀïµÄ¡°´ú¼Û¡± ¿ÉÓá°´úÂëÐ޸ĵÄÁ¿¡±ºÍ¡°ÐÞ¸ÄËùºÄ·ÑµÄʱ¼ä¡±¼ÓÒÔ¹À¼Æ¡£
×¢Òâ 1:³ý·ÇÕâЩ±ä»¯ÐÞ¸ÄÁË֮ǰ¸÷½ÚÌá¼°µÄijЩ¹¦ÄÜ£¬ÄãÕë¶ÔÕâЩ±ä»¯Ëù ×öµÄÐ޸Ķ¼²»Ó¦ÆÆ»µÖ®Ç°ÒѾдºÃµÄ¹¦ÄÜ¡£
×¢Òâ 2:Ìá½»µ½²Ö¿âÖ®ºó£¬master ·ÖÖ§ÐèÈÔȻָÏò±¾½ÚÈÎÎñ֮ǰµÄ½á¹û£¬TA »áµ½²Ö¿âµÄ ·ÖÖ§Éϼì²é±¾½ÚÈÎÎñ¡£
change
ÒÔϸø³öÁË Git µÄÏà¹Ø²Ù×÷Ö¸ÄÏ¡£
…×î³õÔÚ master ÉϹ¤×÷…
git checkout -b change ´´½¨Ð·ÖÖ§
…°´ÉÏÃæµÄÒªÇó½øÐдúÂëÐ޸ą
git add *
git commit -m “change”Ôڸ÷ÖÖ§ÉÏÌá½»
git checkout master Çл»»Ø master ·ÖÖ§
…Ç벻ҪʹÓà git merge change ½øÐкϲ¢ÐÞ¸Ä
…Ç벻ҪʹÓà git branch -d change ɾ³ý·ÖÖ§
ÄãµÄ Git ²Ö¿âÖÐµÄ Object Graph Ó¦ÀàËÆÓÚÏÂͼËùʾ¡£ÆäÖÐÉÏ·½µÄ master ·ÖÖ§ °üº¬Á˱¾½Ú֮ǰµÄ¿ª·¢½á¹û£¬Ï·½µÄ·ÖÖ§ÊÇÕë¶Ô±¾½ÚµÄ±ä»¯ÐèÇóµÄ¿ª·¢½á¹û¡£
……
…
change
master
3.10 ÏîÄ¿½á¹¹
×¢:Èç¹ûÊÖ²áÖиø³öµÄ½Ó¿Ú/ÀàÎÞ·¨Âú×ãÄãµÄÉè¼ÆÐèÒª£¬Çë×ÔÐÐÔö¼ÓÏàÓ¦µÄ°ü¡¢
ÏîÄ¿Ãû:Lab3-ѧºÅ
src java Îļþ×ÔÐÐ×éÖ¯°ü½á¹¹£¬×öµ½ÓÐÐò¡¢ÇåÎú test JUnit ²âÊÔ³ÌÐòĿ¼£¬Óë src ½á¹¹±£³ÖÒ»Ö lib ³ÌÐòËùʹÓõÄËùÓÐÍⲿ¿âÎļþ
doc ʵÑ鱨¸æ
ÆäËû¸¨ÖúĿ¼
Lab Manuals Lab-3 Reusability and Maintainability oriented Software Construction
½Ó¿Ú¡¢À࣬µ«²»Òª¸ü¸ÄÉÏÊö°ü½á¹¹¡£
4 ʵÑ鱨¸æ
Õë¶ÔÉÏÊö±à³ÌÌâÄ¿£¬Çë×ñÑÓê¿ÎÌÃÖÐ Lab3 Ò³Ãæ¸ø³öµÄ±¨¸æÄ£°å£¬×«Ð´¼òÃ÷ ¶óÒªµÄʵÑ鱨¸æ¡£
ʵÑ鱨¸æµÄÄ¿µÄÊǼǼÄãµÄʵÑé¹ý³Ì£¬ÓÈÆäÊÇÓöµ½µÄÀ§ÄÑÓë½â¾öµÄ;¾¶¡£²» ÐèÒª³¤ÆªÀÛë¹£¬¼Ç¼¹Ø¼üÒªµã¼´¿É£¬µ«ÐèÈ·±£±¨¸æ¸²¸ÇÁ˱¾´ÎʵÑéËùÓпª·¢ÈÎÎñ¡£
×¢Òâ:
l ʵÑ鱨¸æ²»ÐèÒª°üº¬ËùÓÐÔ´´úÂ룬Çë¸ù¾ÝÉÏÊöÄ¿µÄÓÐÑ¡ÔñµÄ¼ÓÈë¹Ø¼üÔ´
´úÂ룬×÷Ϊ¸¨Öú˵Ã÷¡£
l ÇëÈ·±£±¨¸æ¸ñʽÇåÎú¡¢Ò»Ö£¬¹ÊÇë×ñÑÄ¿Ç°Ä£°åÀïÉèÖõÄ×ÖÌå¡¢×ֺš¢
Ðмä¾à¡¢Ëõ½ø;
l ʵÑ鱨¸æÌύǰ£¬Ç롰Ŀ¼¡±ÉÏÓÒ»÷£¬È»ºóÑ¡Ôñ¡°¸üÐÂÓò¡±£¬ÒÔÈ·±£ÄãµÄ
Ŀ¼±êÌâ/Ò³ÂëÓëÕýÎÄÏà¶ÔÓ¦¡£
l ʵÑ鱨¸æÎļþ¿É²ÉÓà Word »ò PDF ¸ñʽ£¬ÃüÃû¹æÔò:Lab3-ѧºÅ-Report¡£
5 Ìá½»·½Ê½
½ØÖ¹ÈÕÆÚ:µÚ 17 ÖÜÖÜÈÕÒ¹¼ä 23:55¡£
Ô´´úÂë:´Ó±¾µØ Git ²Ö¿âÍÆËÍÖÁ¸öÈË GitHub µÄ Lab3 ²Ö¿âÄÚ¡£ ʵÑ鱨¸æ:Ëæ´úÂë²Ö¿â(doc)Ŀ¼Ìá½»ÖÁ GitHub¡£
6 ÆÀ·Ö·½Ê½
Deadline Ö®ºó£¬½ÌʦºÍ TA ¶ÔѧÉúÔÚ GitHub ÉϵĴúÂë½øÐвâÊÔ£¬ÔĶÁʵÑ鱨 ¸æ£¬×ö³öÏàÓ¦ÆÀ·Ö¡£