texas christian university cosc 20803 Ð fall, 2016 lab...

12
Texas Christian University CoSc 20803 – Fall, 2016 Lab #1 Due Date: GUI code – Midnight, Thursday, Sep 22, 2016. You should zip together your entire Lab1 Eclipse project GUI (including any images that your project is using). Your zipped file should contain ALL files related to your Lab1 project GUI and MUST be submitted by midnight with TURNIN). MUST include a double-clickable .jar file that can be used to test your project. Finished Project – Midnight, Thursday, Oct 6, 2016. You should zip together your entire Lab1 Eclipse project, including any images that your project is using. Your zipped file should contain ALL files related to your Lab1 project and MUST be submitted by midnight with TURNIN). MUST include a double- clickable .jar file that can be used to test your project. Your code MUST BE thoroughly documented. Important: Also required is a short User’s Manual describing the steps to follow in using your program. Any limitations (or shortcomings) of your program should be clearly enumerated so that I, or the grader, can avoid problems when testing the functionality of your project. The User’s Manual should be turned in at my office (or the Secretary’s office) on Friday morning (Oct 7) by 12:00 PM noon (not accepted late!!!). Language: Java Lab Value: This assignment is worth 250 points total. 50 points will be awarded for your GUI code zipped together and turned in by midnight on Sep. 22. The remaining 200 points may be earned for a successful, fully documented, implementation of the lab requirements (these points will be prorated). Purpose: To exercise your knowledge of sequential and circular linked lists. The data structure you are required to build for this assignment is shown later on in this lab specification. You MUST use this data structure in your program. I realize that Java may provide classes that MIGHT do some of this program for you – YOU ARE NOT ALLOWED TO USE THOSE CLASSES!!!! Also you may NOT use arrays or Vectors in solving this problem. Design your algorithms so that no “statically” allocated arrays or Vectors are needed. You should use node structures consistent with those shown below. Documentation: You are expected to thoroughly document your programs to the extent discussed in class. Your software should contain “preamble” documentation like that taught in CoSc 10403 and CoSc 20203 AND internal documentation consistent with that expected of experienced programmers. If you don’t know what that means – ASK!!! 1

Upload: others

Post on 03-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

Texas Christian University CoSc 20803 – Fall, 2016

Lab #1 DueDate: GUI code –Midnight, Thursday, Sep 22, 2016. You should zip together your

entire Lab1 Eclipse project GUI (including any images that your project isusing). YourzippedfileshouldcontainALL filesrelatedtoyourLab1projectGUI and MUST be submitted by midnight with TURNIN).MUST include adouble-clickable.jarfilethatcanbeusedtotestyourproject.

FinishedProject–Midnight,Thursday,Oct6,2016.Youshouldziptogether

your entire Lab1 Eclipse project, including any images that your project isusing. Yourzipped fileshouldcontainALL filesrelated toyourLab1projectandMUSTbesubmittedbymidnightwithTURNIN).MUSTincludeadouble-clickable.jarfilethatcanbeusedtotestyourproject.

YourcodeMUSTBEthoroughlydocumented. Important:AlsorequiredisashortUser’sManualdescribingthestepstofollow

in using your program. Any limitations (or shortcomings) of your programshouldbeclearlyenumeratedsothatI,orthegrader,canavoidproblemswhentestingthefunctionalityofyourproject.TheUser’sManualshouldbeturnedin at my office (or the Secretary’s office) on Friday morning (Oct 7) by12:00PMnoon(notacceptedlate!!!).

Language: Java

LabValue: Thisassignmentisworth250pointstotal.50pointswillbeawardedforyour

GUIcodezippedtogetherandturnedinbymidnightonSep.22. Theremaining200pointsmaybeearnedforasuccessful,fullydocumented,implementationofthelabrequirements(thesepointswillbeprorated).

Purpose: To exercise your knowledge of sequential and circular linked lists.Thedata

structureyouarerequiredtobuildforthisassignmentisshownlateroninthislab specification. YouMUST use this data structure in your program. I realizethatJavamayprovideclassesthatMIGHTdosomeofthisprogramforyou–YOUARENOTALLOWEDTOUSETHOSECLASSES!!!!

Also youmay NOT use arrays or Vectors in solving this problem. Design youralgorithms so that no “statically” allocated arrays or Vectors are needed. Youshouldusenodestructuresconsistentwiththoseshownbelow.

Documentation: You are expected to thoroughly document your programs to the extent

discussed in class. Your software should contain “preamble” documentationlike that taught inCoSc10403andCoSc20203AND internaldocumentationconsistentwiththatexpectedofexperiencedprogrammers.Ifyoudon’tknowwhatthatmeans–ASK!!!

1

Page 2: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

2

For an example, see the CoSc 10403 ClassInfo website:(http://csfaculty.tcu.edu/10403/DocumentationStandard_MS.htm).

Note:YouarefreetouseJavaDoc.

Background: Itisdifficulttoarriveatanaccuratecountofthenumberofdifferentspeciesoftrees that are indigenous to Texas. A visit to the TexasA&MForest Servicewebsite(http://texastreeid.tamu.edu/content/listOfTrees/)willprovidealistof approximately 130 difference species (from Sweet Acacia to AmericanWitchhazel). The information provided includes techniques for identifyingleaves,howtobuildaleafcollection,howtreesgrow,etc.Itisafunsitetovisit.

Anotherinterestingsiteis: http://texasforestservice.tamu.edu/websites/FamousTreesOfTexas/ Thissite isveryinformativeandprovidesahistoryandpicturesoftreesthat

haveplayedaprominentroleinthehistoryofTexas.Includedare:

1. The Hangman’s Oak (Bandera County, TX. Reportedly 8 men werehangedfromthetreein1863.

2. JumboHollisPecan(SanSabaCounty,TX).Hasthedistinctionofhavingyieldedthelargestpecannutsintheworld.

3. TreatyOak(TravisCounty,TX).StephenF.Austin,the“FatherofTexas”,reportedlysignedanearly treatybetweenTexansandIndiansunder itsbranches.

StillanotherinterestingsiteistheAmericanForestssite: www.americanforests.org/who-we-are-about-us/who-we-are-history/ Thissiteprovidesusefulinformationabouttheproperwaytoplantatreeand

how to protect habitat. The site serves to provide a process for nominatingand registering national champion trees that, due to size and/or age, areentitledtonationalrecognitionandattention.ThissitemaintainstheNationalRegisterofBigTrees,alistofthebiggesttreesinAmerica.

Visitorsareinvitedtonominatecandidatetreesusingapointsystemformula

basedonCircumference(inches)+Height(feet)+¼CrownSpread(feet).Thetreewiththemosttotalpointsiscrownednationalchampion.

Page 3: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

According to the site, the National Championright now is a giant Sequoia living in SequoiaNational Park, California. The tree’scircumferenceis1020inches,ithasaheightof274 feet, anda crownspreadof107 feet.Thetreewasnominatedandplacedinthenationalregistryin1940.

So, what does this have to do with datastructuresyouask?

Assignment: “Oak wilt, one of the most destructive tree

diseases in the United States, is killing oaktreesincentralTexasatepidemicproportions.OakwiltisaninfectiousdiseasecausedbythefungusCeratocystisfagacearum,which invades and disables the water-conducting system in susceptibletrees.Alloaks (Quercusspp.)aresusceptible tooakwilt tosomedegree,butsomespeciesareaffectedmorethanothers.Thesuccessfulmanagementofoakwiltdependsoncorrectdiagnosisandanunderstandingofhowthepathogenspreadsbetweendifferentoakspecies.“

http://texasoakwilt.org/oakwilt/

Oakwilthasbeenfoundinover76countiesandinalmosteverycityinCentral

Texas,aswellasAbilene,Midland,Lubbock,Dallas,Ft.Worth,CollegeStation,Houston,andSanAntonio. Itcanbeaproblemwherever liveoakstendtobethepredominatetree.Itdoesnotmatterwhetherthetreesaretransplantedornaturallygrown.An individual tree’sage, sizeorprevioushealth statusdoesnotmakeitmoreorlesslikelytocontractordiefromoakwilt.

http://texasforestservice.tamu.edu/OakWiltFAQS/

The“COSC20803OakWiltProject”isinterestedinhavingsoftwarethatwould

allowperson(s)toregisterinformationaboutOaktreesinDallas/FtWorthandsurrounding counties (Collin,Dallas,Denton,Ellis, Johnson,Kaufman,Parker,Rockwall, Tarrant, Wise). The software will be modeled after the NationalRegisterofBigTreesbutwillbelimitedtoOaktreespecieslistedonthe“TreesofTexas”websitementionedearlier:

http://texastreeid.tamu.edu/content/listOfTrees/

FortheLab1assignmentyouarecreatingaprogram,utilizingahighlyfriendlyandintuitivegraphicaluserinterface(GUI),whichwillallowausertoreadintree information to populate a circular-linked list (ordered ascendingly bycounty,andwithincounty,by treespecies).YoushoulduseappropriateOOPtechniquesfortheproject.

Page 4: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

ThepurposeoftheassignmentistoimplementanappropriatedatamodelthatmaybeusedtoaccommodateananalysisofhowoakwiltgrowsandspreadsintheproposedTexascounties.

Yourprogramwill be required toprocessdata from several input files – filenamestobeobtainedusingSwing JFileChoosers.Iwillprovide:1. CountyNames.txt–analphabeticallistingoftheDallas/Ft.Worthand

surroundingcounties.2. SpeciesNames.txt - an alphabetical listing of Texas Oak species

names(commonName/scientificName)3. TreeWiltData.txt – a listing (alphabetical by county names and

within county names by species names) of the large Oak trees (scalepoints>=200asmentionedabove)thatsufferwithOakWiltinthecountieslistedinfile#1above.(Formattobediscussedbelow).

OperationalConsiderations:

• UseappropriateGUIcomponents(JComboBoxes,JCheckBoxes,JTextFields,JTabbedPanes,etc.)toaffordtheuserthefunctionalitydiscussedbelow.YouarefreetousetheGUIdesigntechniquestaughtinCOSC10403andCOSC20203.YouarealsofreetouseGUIbuilders(e.g,theEclipseWindowsBuilderortheNetBeansIDEGUIBuilder).

• Yourprogramshouldbeeasytouse–detailsareuptoyou–butyouMUSTprovideashortuser’smanualdescribinghowtouseyourprogram(i.e.,whatkeystrokesarenecessary)andanyfeaturesthatyoufailedtoimplement.

ImplementationConsiderations:

• Yourprogramistobewrittenasa“stand-alone”JavaapplicationusingSwingcomponents.DONOTIMPLEMENTTHISPROGRAMASANAPPLET!!GoodOOPprogrammingtechniquesaretobeused–theMVCdesignpatternisacceptable(andrecommended–seetheCOSC20803websiteforalinktoausefulMVCDemo).

• CircularlinkedlistsMUSTbeusedforthisapplication–followtheguidelinesshownbelow.

Input: Yourprogramshouldprovidea friendlyandintuitiveGUI thatallows theuser todefine

and inputdata tosupport therequired functionality. Howyour interfaceaccomplishesthis is entirely up to you; however, your gradewill be largely based on how easy andintuitiveyourinterfaceis.

Page 5: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

FileFormats: Asmentioned,threedatafileswillbeprovidedforthisassignmentTwohaveverysimplerecordformats.

1) CountyNames.txt–recordsappearinascending,alphabeticalorderbyCountyName:

FormatoftheCountyNames.txtdatafile(namesoccurringalphabetically)countyName1 countyName2 . . . countyNamen

2) Format of the SpeciesNames.txt data file (names occurring alphabetically bycommonName.)

commonName1/scientificName1 commonName2/scientificName2

. . . commonNamen/scientificNamen

3) Thethirdfile,TreeWiltData.txt,willbestructuredaccordingtothefollowingformat:countyNamecommonName/points/circumference/height/crownSpread/yrStartedWilt/yrEndedWilt/personReportingExample: Dallas Chinquapin Oak/353/256/78/76/2007/2016/Billy Bob Thornton ThepointsforthisDallasCountyChinquapinOak(353)werecalculatedusingtheformula:Circumference(inches-256)+Height(feet-78)+¼CrownSpread(feet-76)=353points.Examplerecordsfromthefile:

Denton Emory Oak/498/393/84/83/2012/2016/Charles Davis Nuttial Oak/281/211/49/84/1986/2015/Kate Smith Post Oak/530/394/112/94/2012/2016/Joesph Tipton Southern Red Oak/525/348/154/93/1982/2012/Teddy Roam Texas Oak/696/557/102/150/2012/2015/Wilma Davis $$$$$ Ellis Mossy cup Oak/480/327/125/112/2003/2010/Pat Young Shumard Oak/223/162/46/61/2011/2015/Upton Wilson

Note: Thedeliminator“$$$$$”markstheendofonecounty’sinformationandthebeginning

ofthenextcounty’sinformation.

Page 6: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

Requirednodestructures:Oakwiltdatarecords,withtheiraccompanyingdata,shouldbereadandprocessedintoacircular-

linkedlistwithnodesofthefollowingformat:

Note:inthefollowingdiagram-

countyName speciesNodePtrcountyNameNodePtr

CountyNameNode:

countytreeCount

commonName treeNodePtrSpeciesNode: scientificName numTrees speciesNodePtr

treeNodePtr

Apoints crownSpreadTreeNode: circumferance height treeNodePtrnameyrStart yrEnd

Page 7: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

RepresentationoftheRequiredDataStructure(allinkedlists)isshownbelow:

listHead

Page 8: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

Yourprogramshouldprovidethefollowingbasicfunctionality:

Methods: Three Java interfaces are shownat thebottomof this assignment. YourprogramMUST implement these three interfaces. Additional decomposition isrecommended.

Inaddition,yourprogramshouldprovideatleastthefollowingfunctionality.

1. createOakWiltLL . . . causes a “Header” node to be created for theOakWiltLL and data records from the three files mentioned above to be read(CountyNames.txt, SpeciesNames.txt, & TreeWiltData.txt) and used topopulatetheOakWiltLL.Youshouldprovidesomefacilityfortheusertoenterfilenames(JFileChooserorJTextFields).

Once your initial linked list is constructed, the following functionality should beprovidedtoallowausertointeractwithyourdatastructure:2. displayWiltedTreesByCounty . . .printsoutall informationabouttreessuffering with oak wilt in a specific county. To do this, you will need to design asuitableoutputformat.AJTextArea(orJList)maybeusedtodisplayeachtree’sinformation(county,commonandscientificname,points,andotherinformation).3. displayWiltedTreesByCommonName . . .displayallinformationfortreeswithaspecifiedcommonname.UseanappropriateGUIcomponenttoallowtheusertoeasilychoosethecommonname.

4. displayAllTreesWithOakWilt . . . display all information for treessufferingwithoakwiltinallcounties.UseanappropriateGUIcomponenttoallowtheusertoeasilychoosethecommonname.

5. displayTreesWithPointsExceeding(value). . .displayallinformationfortreeswithscalepointsexceedingthespecifiedvalue.

6. addNewTree....somefacilityshouldbeprovidedtoaddanewtreethathasrecently developed oak wilt. Your interface should permit the user to enter allinformationaboutthetree(countyName,commonName,,treedimensions,andnameperson registering the tree). Note: the database contains only trees having a scalepoint value >= 200. The user should be alerted if the calculated value does notmeasureupandthetreeentryshouldberejected.(a) deleteTree . . . sadly,sometreesarecutdownafteratotalwilttotolimittheinfection.Theseshouldberemovedfromyourlinkedlist.

Page 9: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

BONUS:(15pointseach)

1. Provide a capability for the user to save the current status of the tree data structure (at the end of the day) so that the existing information may be reloaded at the beginning of a new day.

2. Provide the ability to determine the name (both common and scientific) of the oak tree species that has the greatest susceptibility to oak tree wilt (i.e., the tree occurring with the greatest frequency in the data base).

Input: Yourprogramshouldprovideavery friendlyand intuitiveGUI thatallowsthe

usertodefineandinputdatatosupportthefunctionalityoutlinedabove.Howyourinterfaceaccomplishesthisisentirelyuptoyou;however,yourgradewillbelargelybasedonhoweasyandintuitiveyourinterfaceis.

Requirements:Additionally,yourprogramisrequiredtoimplementthreeJavainterfaces-shownbelow.YouMUSTincludeandcompilethesethreeJavainterfaceswithyourprogram:Interface#1:CountyNamesNodeInterface - (** should be included as a part of your Lab1 project – create your own “public class CountyNamesNode implements CountyNamesNodeInterface”)

public interface CountyNamesNodeInterface { // ******************PUBLIC METHODS****************************************** // public String getCountyName(); // --> returns the countyName of the node being pointed to // // public void setCountyName(String cn); // --> sets the countyName of the node being pointed to to cn. // // public int getNumTrees(); // --> returns the numTrees field of the CountyNode being pointed to // // public void setNumTrees(int nt); // --> sets the numTrees field of the CountyNode being pointed to to nt. // // public CountyNode getDown(); // --> returns the value of the downPtr for the specified CountyNode // // public void setDown(CountyNode ptr); // --> sets the downPtr of the specified CountyNode to ptr // // public SpeciesNode getRight(); // --> returns the value of the rightPtr for the specified CountyNode // // public void setRight(SpeciesNode ptr); // --> sets the rightPtr of the specified CountyNode to ptr //**************************************************************************

Page 10: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

/** * Protocol for CountyNamesNodeInterface * @author James Comer */ //Method signatures public String getCountyName(); public void setCountyName(String cn); public int getNumTrees(); public void setNumTrees(int nt); public CountyNode getDown(); public void setDown(CountyNode ptr); public SpeciesNode getRight(); public void setRight(SpeciesNode ptr); } Interface#2:SpeciesNodeInterface - (** should be included as a part of your Lab1 project – create your own “public class SpeciesNode implements SpeciesNodeInterface”) public interface SpeciesNodeInterface {

// ******************PUBLIC METHODS****************************************** // public String getCommonName(); // --> returns the commonName field of the specified SpeciesNode // // public void setCommonName(String s); // --> sets the commonName field of the specified SpeciesNode to s // // public String getScientificName(); // --> returns the scientificName field of the specified SpeciesNode // // public void setScientificName(String s); // --> sets the scientificName field of the specified SpeciesNode to s // // public int getNumTrees(); // --> returns the numTrees field of the specified SpeciesNode // // public void setNumTrees(int n); // --> sets the numTrees field of the specified SpeciesNode to n // // public SpeciesNode getRightPtr(); // --> returns the rightPtr field of the specified SpeciesNode // // public void setRightPtr(SpeciesNode p); // --> sets the rightPtr field of the specified SpeciesNode to p // // public TreeNode getDownPtr(); // --> returns the downPtr field of the specified SpeciesNode // // public void setDownPtr(TreeNode p); // --> sets the downPtr field of the specified SpeciesNode to p // // public void setLastPtr(TreeNode p); // --> sets the lastPtr field of the specified SpeciesNode to point to p // // public TreeNode getLastPtr); // --> returns the lastPtr field of the specified SpeciesNode // //***************************************************************************

Page 11: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

/** * Protocol for SpeciesNodeInterface * @author James Comer */ //Method signatures public String getCommonName(); public void setCommonName(String s); public String getScientificName(); public void setScientificName(String s); public int getNumTrees(); public void setNumTrees(int n); public SpeciesNode getRightPtr(); public void setRightPtr(SpeciesNode p); public TreeNode getDownPtr(); public void setDownPtr(TreeNode p); public TreeNode getLastPtr(); public void setLastPtr(TreeNode p);

}

Interface#3:TreeNodeInterface - (** should be included as a part of your Lab1 -project create your own “public class TreeNode implements TreeNodeInterface”) public interface TreeNodeInterface {

// ******************PUBLIC METHODS****************************************** // public double getPoints(); // --> returns the points field of the specified TreeNode // // public void setPoints(double d); // --> sets the points field of the specified TreeNode to d // // public double getCircumferance(); // --> returns the circumferance field of the specified TreeNode // // public void setCircumferance(double d); // --> sets the circumferance field of the specified TreeNode to d // // public double getHeight(); // --> returns the height field of the specified TreeNode // // public void setHeight(double d); // --> sets the height field of the specified TreeNode to d // // public double getCrownSpread(); // --> returns the crownSpread field of the specified TreeNode // // public void setCrownSpread(double d); // --> sets the crownSpread field of the specified TreeNode to d // // public String getYrStarted(); // --> returns the yrStarted field of the specified TreeNode // // public void setYrStarted(String s); // --> sets the yrStarted field of the specified TreeNode to s // // public String getYrEnded(); // --> returns the yrEnded field of the specified TreeNode

Page 12: Texas Christian University CoSc 20803 Ð Fall, 2016 Lab #1csfaculty.tcu.edu/comer/20803/Lab1/Lab1.pdf · 3 { // // // // // // // //***** ***** /**

// // public void setYrEnded(String s); // --> sets the yrEnded field of the specified TreeNode to s // // public String getName(); // --> returns the personName field of the specified TreeNode // // public void setName(String s); // --> sets the personName field of the specified TreeNode to s // // public TreeNode getDownPtr(); // --> returns the downPtr field of the specified TreeNode // // public void setLastPtr(TreeNode p); // --> sets the downPtr field of the specified TreeNode to p // //**************************************************************************** /** * Protocol for TreeNodeInterface * @author James Comer */ //Method signatures public double getPoints(); public void setPoints(double d); public double getCircumferance(); public void setCircumferance(double d); public double getHeight(); public void setHeight(double d); public double getCrownSpread(); public void setCrownSpread(double d); public String getYrStarted(); public void setYrStarted(String s); public String getYrEnded(); public void setYrEnded(String s); public String getName(); public void setName(String s); public TreeNode getDownPtr(); public void setDownPtr(TreeNode p);

}