ࡱ> x_y Oh+'0( <H d p |OThe Captains Mistress Additional notes for guidance based on the case studyhe  Lloyd Mooreloy Normal.dot Lloyd Moore9oyMicrosoft Word 8.0e@ @Uǜ@pY latesE@A1( A ՜.+,D՜.+,|8 hp|   aj OThe Captains Mistress Additional notes for guidance based on the case study Title 6> _PID_GUIDAN{EA9BF3A7-2599-11D4-A4F3-9A4FF0The Captains Mistress Additional notes for guidance based on the case study. Stage 1. Creating the playing matrix. Array or Vector? An array remains a fixed size throughout its existence, whereas a vector can dynamically grow or shrink as needed. In this case we are unlikely to want to change the size of the matrix so we shall use an array. We need to create a 2 dimensional array, which consists of rows and columns; this is known in Java as a multidimensional array or an array of arrays. First, we must declare the constant variables in the Board class: - private static final int ROW_SIZE = 6; private static final int COLUMN_SIZE = 7; // note upper case // This sets the size of the array of arrays, which will be declared thus: - private char the_sqrs [] []; Next we must write a constructor method so we can create a new playing grid for a new game: - public Board ( ) { the_sqrs = new char [ROW_SIZE] [COLUMN_SIZE]; later, we will want to access each move in turn, so we will need to run a for loop and call setChanged ( ); Observer / Observable. Why do we use this? It is not strictly necessary but it makes for a cleaner design as it separates the functionality from the input and output. There are 3 stages to create Observer / Observable : - Extend the class so that it inherits from the library class observable. e.g. import java.util.observable; public class Game extends observable . then incorporate the required methods from observable, such as setChanged( ). Whichever class implements observer must then provide an implementation to update this states what the observer must do when the observed class has been updated. e.g. Class Game_Observer implements observer {. } public void update (observable o, objects a) {output } In the client class: - Create an observer in the class_observer Add it to the Game (in this case) Perform the functionality Notify its observers. e.g. public class Application { private Game_observer the_game_observer; } public Application ( ) { the_game_observer = new Game_observer (the output); the_game_observer.addObserver (the_game_observer); the_game.action; the_game.notifyObservers ( ); } Stage 2. Dynamic Linked Lists This is used to ser up a linked list of objects, then scan through the list and print out their moves. The list of moves of the Turn objects is encapsulated in the Turnlist class. class TurnList { private Turn list; private Turn next_turn; Turnlist ( ) { list = null; // initialises the list reference } public void add (int new_move) { Turn new_turn = new Turn (new_move); // creating a new Turn node to be added Turn current; if (list = = null) /* if not the end of the list (last node always has a null value) */ list = new_turn; else Data Structure Chart Stage 1 GAME state at the start of the game We are assuming that a new game has started and that the computer, which goes first by default, has gone in column 6, row 1. Therefore, the player is now the human = 0, the moves become 1. BOARD_1BOARDRef 1the_computerChar*the_humanChar0the-playerChar0the_game_isInt2messageStringPlayer *GameOverBooleanfalse ROW_SIZEint6COLUMN_SIZEint7the_sqrs [ ] [ ]charRef 2the_movesint1blankchar the_end_of_gamebooleanfalseCurrentColumnint6CurrentRowint1                                                 *  76C170}Oh+'0( <H d p |OThe Captains Mistress Additional notes for guidance based on the case studyhe  Lloyd Mooreloy Normal.dot Lloyd Moore9oyMicrosoft Word 8.0e@ @Uǜ@pY latesE@A1( APQZ[xy]^9:cpq"PQZ[xy]^9:cpq"#$<=QR  P s yvs=e  f  MN|~ [\]  v,"#$<=QR  P s     D h  & Fh & F     D h   > s $|yvspmj#%45 IJTUVZzDHch~           79)   > s 8$&t !FG).0T$$l  $$&t !FG).01;@BCNSUVbfhiqx$%379:EIKLMPUZ_dinst 4BV01;@BCNSUVbfhiqxHLLd`$$$l  $%379:EL|D@|TH$$$l "EIKLMPUZ_dinstx|tt$$lR J $$l "$tx|   !" 2ttt$$lR J $QZx$= !GMOPQUVZ[_`deijno"&2|4488888888 9"9P9R999999999 ::L<@ZBnB^F`FbFdFFFFFFG.G0G~GGGGGGGGGG*J jUmH>*5U44B5D55x6F777~888 999l:n:p:;;<<<<><@x@AAXB & FQZx$= !GMOPQUVZ[_`deijno"&2|4488888888 9"9P9R999999999 ::L<@ZBnB^F`FbFdFFFFFFG.G0G~GGGGGGGGGG*JN jUmH>*5VXBZBlBnB~BB C"CfCVD$EEE\F^FFF~GGJHLHNHlInIIIJJ & Fmn on the case study Lloyd Moore Lloyd Moore [(@(NormalCJmH 2`2 Heading 1$@&5>*0`0 Heading 2$@&>*<@< Heading 3$<@&OJQJ@@@ Heading 4$<@& 5OJQJ<A@<Default Paragraph Font$/@$List (2@(List 2 66D@6 List Continue x:E@":List Continue 2 6x*B@2* Body Textx<C@B<Body Text Indent x2PQZ[xy]^9:cpq"#$<=QRPsDh>s        $ - . 7 ? E F N X \ ^ _ k o q r       $ ( , 0 4 8 < = A E I M Q U Y Z ^ b f j n r v w {  e f @z{ LkCD @@@ @@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ This is used to set Study this class to see how it works. Basically you must create a turn node to be added to the list, then run an  if statement to check the state of the list, then add the node if appropriate. You must also create a Turn class to store a move and a reference to another turn. Stage 3. Hashing Hashing is a technique used for sorting items so they can be found efficiently. Items are stored in a hash table. A number called a hash code (or hash value) is calculated from the target value using a hash method (or hash function). The hash code is then scaled to the size of the hash table, often by using the remainder (%) operator. The result, the hash index, designates the position of the target value in the hash table. I have come up with a nmonic that may help you remember this: - I Items are stored in a hash table. N Number is calculated using a hash method. S Number (hash code) is Scaled to the size of the hash table - HI resulting in a Hash Index - P which designates the Position of the target value in the hash table. As an aside, it may be worth just refreshing yourselves on binary and linear searching in case this comes up, (Chris seems to think it may). Hope this helps to clarify some of the issues raised last Thursday. Love and kisses. Lloyd. XBZBlBnB~BB C"CfCVD$EEE\F^FFF~GGJHLHNHlInIIIJJ & F [(@(NormalCJmH 2`2 Heading 1$@&5>*0`0 Heading 2$@&>*<A@<Default Paragraph Font2$<=QRPsDh>s        $ - . 7 ? E F N X \ ^ _ k o q r       $ ( , 0 4 8 < = A E I M Q U Y Z ^ b f j n r v w {  e f @z{ LkCD       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@         *J " 0E4XBJ & $t" Unknown Lloyd Moore8AG@"F(  HB 8 C DHB 9 C DHB :@ C DHB ; C DNB < S DNB = S DNB > S D NB ? S D NB @ S D NB A S D NB B S D HB C C DHB D C DNB E S DB S  ? N r s      DP{P{ tC{P{tEPpt9@&@&t8"@&t;00:t:0@&t<0&p&t=0&p&t>0&p&t?0&p&t@0&p&tA0&p&tB0&p&t   Lloyd MooreE:\The Captain.doc Lloyd MooreE:\The Captain.doc Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd MooreE:\The Captain.doc Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd MooreE:\The Captain.doc m!V s%>hho(.hho(.88o()m!Vs%@ZZȧZZ{C$Eƀb'/F & FC$5>*G >*CJmH 0J $%     d o t ?@z    $%)KLMNP^@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ &P/ =!"#$% This is used to set Study this class to see how it works. Basically you must create a turn node to be added to the list, then run an  if statement to check the state of the list, then add the node if appropriate. You must also create a Turn class to store a move and a reference to another turn. Stage 3. Hashing Hashing is a technique used for sorting items so they can be found efficiently. Items are stored in a hash table. A number called a hash code (or hash value) is calculated from the target value using a hash method (or hash function). The hash code is then scaled to the size of the hash table, often by using the remainder (%) operator. The result, the hash index, designates the position of the target value in the hash table. I have come up with a nmonic that may help you remember this: - I Items are stored in a hash table. N Number is calculated using a hash method. S Number (hash code) is Scaled to the size of the hash table - HI resulting in a Hash Index - P which designates the Position of the target value in the hash table. As an aside, it may be worth just refreshing yourselves on binary and linear searching in case this comes up, (Chris seems to think it may). Hope this helps to clarify some of the issues raised last Thursday. Love and kisses. Lloyd. @@@@@@@@@@@@@@@@@@@@@@@@@@@@   !"$2233z4|4444l$$lR J $ [(@(NormalCJmH 2`2 Heading 1$@&5>*0`0 Heading 2$@&>*<A@<Default Paragraph Font2$<=QRPsDh>s        $ - . 7 ? E F N X \ ^ _ k o q r       $ ( , 0 4 8 < = A E I M Q U Y Z ^ b f j n r v w {  e f @z{ LkCD       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@         L< " 0E4><  $t" Unknown Lloyd Moore8AF@"E(  HB 8 C DHB 9 C DHB :@ C DHB ; C DNB < S DNB = S DNB > S D NB ? S D NB @ S D NB A S D NB B S D HB C C DHB D C DNB E S DB S  ? N r s      DP{P{ tC{P{tEPpt9@&@&t8"@&t;00:t:0@&t<0&p&t=0&p&t>0&p&t?0&p&t@0&p&tA0&p&tB0&p&t   Lloyd MooreE:\The Captain.doc Lloyd MooreE:\The Captain.doc Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd MooreE:\The Captain.doc Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd MooreE:\The Captain.doc m!V s%>hho(.hho(.88o()m!Vs%@ ȧ {C$Eƀb'/F & FC$5>*G >*CJmH 0J $%     d o t ?@z    $%)KLMNP^_cdijkln ~@@AH@@J@@@@L@@@@"2A$2@Z@A&2A@AL2@2A03A63A83@3A3A3@x4@z4A|4A4@4A4@4@4AD5@5@5@7@x8A8A8A8A8A8@8A8A8A8A8A9@9A 9A"9AP9AR9AZ9@9A9A9A9A9A9A9A9A9A9@9A9A9A9A :A:@j:A:@ ;@<@<@@@@@@AJ<@@$@@B$@GTimes New Roman5Symbol3& Arial"qhJEFjuE!r0dzNThe Captain s Mistress  Additional notes for guidance based on the case study Lloyd Moore Lloyd Moorec/||P|P|/|lcL[LckssP|O|/|P|/|klc@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @        @ @ @ @ @ @ N " 0E4XBJ & $t" Unknown Lloyd Moore8AG@"F(  HB 8 C DHB 9 C DHB :@ C DHB ; C DNB < S DNB = S DNB > S D NB ? S D NB @ S D NB A S D NB B  S D HB C C DHB D C DNB E S DB S  ? N r s      DP{P{ tC{P{tEPpt9@&@&t8"@&t;00:t:0@&t<0&p&t=0&p&t>0&p&t?0&p&t@0&p&tA0&p&tB0&p&t Lloyd MooreE:\The Captain.doc Lloyd MooreE:\The Captain.doc Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd MooreE:\The Captain.do_cdijkln ~@@AH@@J@@@@L@@@@@A@@Z@A@A@A*@@v@AAAAAA@AAAAA@VB@XBAZBAfB@jBAnB@|B@BA"C@dC@fC@E@VFA^FA`FAbFAdFAF@FAFAFAFAFAF@FAFAGA.GA0GA8G@|GA~GAGAGAGAGAGAGAGAG@GAGAGAGAGAG@HHAhH@H@I@I@@@@@@A(J@B$@GTimes New Roman5Symbol3& Arial"qhJEFnuEY Y !r0dNThe Captain s Mistress  Additional notes for guidance based on the case study Lloyd Moore Lloyd Mooren/|0|P||/|/|P|JP|ҌьҌҌn/|P|P|/|/|/|P|JPҌҌҌG $"bjbjَ N]  \ $~~~~~       $b%V': r: ~~kP..~~    V@ ~,$`y彿   Root Entry F`٤`y彿l1TableZB  D+H(WordDocument S DZBgNSummaryInformation(ZB  S   D $%&'()*,-./0123456789:;c>?@AB=FGHIJKLMNOPQRSTUVWXYdefhkmnDocumentSummaryInformation 8S DCompObjZB  S Dj 0Table S DZB En(DZB"S D  FMicrosoft Word Document MSWordDocWord.Document.89q ՜.+,D՜.+,|8 hp|   aj OThe Captains Mistress Additional notes for guidance based on the case study Title 6> _PID_GUIDAN{EA9BF3A7-2599-11D4-A4F3-9A4FF076C170} Oh+'0( <H d p |OThe Captains Mistress Additional notes for guidance based on the case studyhe  Lloyd Mooreloy Normal.dot Lloyd Moore8oyMicrosoft Word 8.0e@4@Uǜ@t6i彿Y c Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd Moore4C:\WINDOWS\TEMP\AutoRecovery save of The Captain.asd Lloyd MooreE:\The Captain.doc m!V s%>hho(.hho(.88o()m!Vs%@ȧC$Eƀb'/F & FC$5>*G >*CJmH 0J |PQZ[xy]^9:pq"#$%<=QRPDh     d e f o t ?@z    $%)KLMNP^_cdijkln CD~0@0@0@0@0@0@0@0 @0 @0 @0 @0 @0r @0t @0 @0 @0"@0$@0@0@0@0d@0f@0D@0F@1H@0J@0x@0z@0@0@0 @0 @0@06@0@0@0@06@0@0@0@00@1:@0>@0p@0@1B@0L@0@0@0 @0 @0@1@0Z@0l@0n@1@1@1*@0v@1x@1A1A1A0A0A1A1A1A0VB0XB1ZB1fB0jB0lB1nB0|B0B0 C1"C0dC0fC0VD0$E0E1N1 F0VF0\F1^F1`F1bF1dF1F0F1F1F1F1F1F0F1F1G1.G10G18G0|G1~G1G1G1G1G1G1G1G1G0G1G1G1G1G1G0HH1hH0H0lI1nI0I0I0I0J1J0@0@0@0B$@GTimes New Roman5Symbol3& Arial"hJEFuE Y Y $r0dNThe Captain s Mistress  Additional notes for guidance based on the case study Lloyd Moore Lloyd MooreJ3t3TT֥7G 4"bjbjَ P]n(+++++$+Z?Z?Z?Z? f?\$+T@@@@@'G'G'GLLLLLLL$TVLf+'GE'G'G'GL;G++@@k?.;G;G;G'G +@+@L$+$+++++'GL;G ;GEKV:L@++L@?$ l$+6Z?1G zL Root Entry F`٤ l{1TableZB  D+H(WordDocument S DZBvPSummaryInformation(ZB  S   D$  !"#<%&'(),-./0123456789:;cC>?@ABZ=FGHIJKLMNOPQRSTUVWX[\]^`abodefpqrstuwz|}DocumentSummaryInformation 8S DCompObjZB  S Dj 0Table S DZB EWDZB"S D  FMicrosoft Word Document MSWordDocWord.Document.89q ՜.+,D՜.+,|8 hp|   aj OThe Captains Mistress Additional notes for guidance based on the case study Title 6> _PID_GUIDAN{EA9BF3A7-2599-11D4-A4F3-9A4FF076C170} Oh+'0( <H d p |OThe Captains Mistress Additional notes for guidance based on the case studyhe  Lloyd Mooreloy Normal.dot Lloyd Moore9oyMicrosoft Word 8.0e@ @Uǜ@pY