YOUR NAME: DATE: LAST FOUR DIGITS OF YOUR UF-ID: Please Print Clearly (Blck Letters) YOUR PARTNER S NAME: DATE: LAST FOUR DIGITS OF PARTNER S UF-ID: Please Print Clearly Date Assigned: 15 February 2013 IN CLASS Date Due: 01 March 2013 E-SUBMISSION f Parts II and III In this hmewrk assignment yu may wrk in grups f tw persns nly. Yu may nt cpy frm thers, and yu may nt cpy cde frm the Internet, textbk, r ther surces. Hwever, yu may study with thers r read yur textbk t determine general slutins. Then yu must cmplete the prblems as yur wn wrk, nt cpying thers wrk. Questins abut this hmewrk shuld be addressed t yur TA first. Yu can find yur TA s email, ffice hurs, etc. at the class website: http://www.cise.ufl.edu/~wchapman/cop2800/fficehurs.html This hmewrk has three parts: (I) Vcabulary Questins, (II) Regular Prgram, (III) Advanced Prgram. There is n penalty fr guessing. Part I. Vcabulary Questins [10 pints ttal] Vcabulary: (terms yu need t knw t discuss the subject intelligently) Define the fllwing terms using 1-3 sentences (and a diagram, if needed): [2 pints each] a. Duble (datatype in Java) b. Shrt (datatype in Java) c. Character array d. Re-cmpilatin e. Lp index Part II. Regular Prgram Use yur text editr (Ntepad++) t generate a file called "Part1.txt". Include this file in the ZIP file alng with the cde fr Parts II and III. Yu must have in the upper right-hand crner: (i) COP2800-S13-HW3-PartI, (ii) yur name, and (iii) last fur digits f yur UFID. [20 pints ttal] TASK: Create a Java Prgram that displays TicTacTe (this assignment is the first half secnd half that actually plays TicTacTe t appear in Assignment 4). Like Assignment #2, this
ne is designed t make yu think, s mst f the cde is nt prvided. Yu have t d mre wrk here but we allw yu t wrk in grups f tw, s that shuld make it easier fr yu. PROGRAMMING PROCEDURE: (1) Use the fllwing pseudcde (this is nt Java cde) as the basis fr making a Java Class called TicTacTe, with methds displayttt and updatettt. Cmments are in green typeface, and reserved keywrds are in bld blue; bld red typeface shws where yu shuld insert yur name and cde. The text that yu will utput t the screen is shwn in brwn typeface. (2) Enter the Java cde that yu make frm the example belw. (3) Save yur cde in file TicTacTe.java (save frequently t avid wrk lss), then cmpile using the Java tls that yu dwnladed t yur laptp cmputer. Make sure it runs. // Pseudcde fr COP2800 Assignment #3: First Half f TicTacTe Prgram // Objective: Build an interface and display fr TicTacTe Game // Designed and Cded by: <yur name> Date: 01 Mar 2013 Declare a public class called TicTacTe Ex: public class TicTacTe { public TicTacTe () { } Make a character array structured as TicTacTeArray[1..N][1..N] Ex: int N = 3; FOR TEST PURPOSES ONLY, WILL CHANGE LATER char[][] TicTacTeArray = new char[n][n]; The array TicTacTeArray shuld be available t all subclasses and their methds in the class TicTacTe The first dimensin f the array (indexed frm 0 t N-1) references the gamebard rw, and shuld be indexed using variable i The secnd dimensin f the array (indexed frm 0 t N-1) references the gamebard clumn, and shuld be indexed using variable j Fr this assignment, all array values will be initialized (set at the beginning f the prgram) t *. Only the values X, O, and * will be allwed in the array. At the start f the game, if N = 3, yur TicTacTeArray shuld lk like this: Clumn 0 1 2 TicTacTe +------ Step = 0 0 * * * Player = Rw 1 * * * 2 * * * Winner = Declare a public methd t display the TicTacTeArray bject as shwn abve, called displayttt, which yu will invke as TicTacTe.displayTTT(). Yu will need t be sure that each game is initialized as shwn abve, then each step (when a player enters a
symbl) is incremented. When the screttt methd (t be develped in Part III) is invked, if there is a winner, then the winner s symbl (X r O) is displayed t the right f Winner =. Because we are studying strings and characters, we will ask yu t cnvert each rw f the display (as shwn abve) t a string, then use System.ut.println() t display the string. Declare a public methd t update the TicTacTeArray bject shwn abve, called update, which yu will invke as TicTacTe.updateTTT(sym, rw, cl) where the argument sym is a char (character-valued) variable that can have values X r O and rw, cl are integer-valued variables that range frm 0 t N-1. In ther wrds, This methd will accept a character as an argument Ex: public static vid update(char sym, int rw, int cl) { cde fr the methd ges here } This methd will update the TicTacTeArray data structure by placing the play symbl sym in the rw and cl(umn) f the array dented as arguments t the methd. Make a test rutine (Test.java) that will test the crrect peratin f the TicTacTe class with methds displayttt and updatettt (this is up t yu t design and cde). After yu have designed, entered, cmpiled, and tested yur cde, then d the fllwing: (4) Make sure yur cde runs crrectly by using multiple test cases. (5) Submit yur cde electrnically with yur slutin t Part III, as described belw. Part III. Advanced Prgram [40 pints ttal] Prgramming with Arrays, Characters, and Strings. Perfrm the fllwing steps: (1) Create the fllwing structure with TicTacTe, and a Test2 class, as described belw. Subclass: UserTicTacTe is a subclass f the class TicTacTe that extends TicTacTe and uses the TicTacTeArray frm Part II. Methd 1: PrmptUser Prmpt the user fr an input character (an integer N frm 1 t 10 t start the prgram; r a symbl, rw number, r clumn number with which t update the array like this: Initial Prmpt: Symbl Prmpt: Rw Prmpt: Clumn Prmpt: Enter TicTacTe Array Size: Enter Symbl (X r O): Enter Rw t Place Symbl: Enter Cl t Place Symbl: Methd 2: CheckSymbl The initial prmpt and rw/clumn prmpts will read an int and check bunds t be sure the number is in range. If ut-f-range, then an errr message will be displayed and the user will be
prmpted again. If there are five cnsecutive errrs, the prgram will terminate. The symbl prmpt will read a char and will check t see if it is an X, O, r Q (quit the prgram). If an X r O is encuntered, then the methd will check t see which symbl was played previusly. If an X was played previusly, and the answer t the current symbl prmpt is nt an O r Q (quit the prgram), then an errr message (ILLEGAL SYMBOL) will be displayed and the user will be prmpted again. After five cnsecutive errrs, the prgram will terminate. A symmetric check will be perfrmed when an O was the previus symbl. Methd 3: ScreTTT by checking (every time the TicTacTeArray is updated) fr any rws, clumns, r majr/minr diagnals that have N X s r N O s. If these are fund then the array is displayed with X r O as the winner, as apprpriate. Ties will be detected in Assignment #4, when we add sme intelligence t the prgram. Class: Test2 (i) will run the PrmptUser methd t first set up the array size (by prmpting fr N), then (ii) will run the game by prmpting fr sym, rw, and cl variables and (iii) checking fr errrs, (iv) updating the TicTacTeArray, and scring using ScreTTT. (2) Be careful abut the way yur methds are invked [Hint: Remember hw we invked class.methd in Assignment #1.] (3) Dcument yur cde fully (as in the example in Part II). Cmpile yur cde and get it running, then test it thrughly t be sure it wrks befre yu submit yur cde. Part IV. Extra Credit (text file like Part I, submit nline) [10 pints each] EC-1. What cnditins will the cde in Parts II and III nt detect? Describe exactly why this happens, and hw the cde culd be fixed (if needed) s it des detect these cnditins. EC-2. What can yu say (supprted by analysis) abut the size N f the TicTacTe array? (Hint: Hw much lnger will it take t play the game as N increases by a factr f tw?) Please d this part electrnically. Use yur text editr (Ntepad++) t generate a file called "Part4.txt". Include this file in the ZIP file alng with the cde fr Parts II and III. Yu must have in the upper right-hand crner: (i) COP2800-S13-HW3-PartIV, (ii) yur name, and (iii) last fur digits f yur UFID.
Electrnic Submissin f Parts II and III. Put all files yu created in Parts I thrugh III in a single ZIP file. Yur ZIP file shuld cntain all the files specified in Parts I thrugh III. Submit this ZIP file electrnically per the instructins at: http://www.cise.ufl.edu/~wchapman/cop2800/submit Part V. Evaluatin f Submitted Cde Grading: Cde des nt cmpile r run = 0 pints. Cde cmpiles but des nt run = < 20 percent f pints. Cde runs but wrng results = 21 t 50 percent f pints. Cde runs with crrect results but n dcumentatin (e.g., green cmments in Part II) = 51 t 70 percent f pints. Cde cmpiles and runs, crrect results, dcumentatin present = 71 t 100 percent f pints.