Anda di halaman 1dari 5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

Likethiscourse?BecomeanexpertbyjoiningtheJavaProgramming:ObjectOrientedDesignofDataStructuresSpecialization
(/specializations/javaobjectoriented).
Upgrade

CourseHome(/learn/objectorientedjava/home/welcome) Week3(/learn/objectorientedjava/home/week/3) CheckYourKnowledge

CustomizingMarkers
YoumaydownloadaPDFofthesedirectionshere:https://d396qusza40orc.cloudfront.net/phoenixassets/objectoriented
java/Module%204%20PA%20Instructions.pdf
(https://eventing.coursera.org/api/redirectStrict/IDcqa7eWEn8NfY3GVLJb7RPA5iAhJly0HpAskhTKv6EUdD2AhlQDhKI9a2F7SF5wRPh19d4v8JkwH9NxBkBxAA.p
YZWROGrmgBA0VaXmeerg.t1AdIxVzI2Ix_lIDJ73IlEd4j2EU6UsrRpC9kU1AF8AN4DlCobwefA4FnwoZlEuW5ewu6FWwLT0wmrziH8E
AmKeRdNZ8Qm9ITykctmoxWfu1yDri
rXJWjA5H_4x0IJOnOlEH1AixbczO8jSSAgFUkcx_TvZ5tHHoqIOzdsDPdW3Ev9MskohuFcHZeHdRAMgZWOERnG_u9YAxtRLnTL8I9IBMBvzDfL18brNDdZ6KpxIFbL
GipN58KxWkbYioTAewIvOAXDOkWSerqxbwrpN_mCqbNNNtYBtKowslDuYE3YykJcvnDMhhfKs5dCrKAw4r0dWYGHZEXs1HUkrqQ9x2xf3SmRMt4w2TuJYELTbThC
CRgaHp5_Nyr1Q8g24p47gy5jdgdkRVQ0Wy
ewYCIO5JCpi5XUihiobVO_S48mrdXcM9vTZNGrHdUGr3qiX8MHREczvOVb0Qt61BULRjbqAAVC6n2A62OoDx5BCh8v_2fFvFXrzjDLsyLrXiB0_)
Justlikeinmodule3,thisassignmentbuildsontheassignmentyoudidpreviousmodules.Onceagain,youwillnotsubmityourcodeforgrading.Rather,afteryou
havecompletedallpartsofthisassignmentyouwilltakeanendofmodulequiz.Andagainremember,it'sdoingtheprogrammingwhereyouwilllearnthemost
(andhavethemostfun!).
IFYOUAREWORKINGOFFLINE:Remembertofollowtheinstructionsbelow,andlookforthedocumentationresourceswerecommendsoyoucandownload
themifyoudon'thavethemalready.

Learningoutcomes:
Organizeacomplexapplicationbyusingseveraldifferentclasses.
Buildaclasshierarchytoreflectthedifferentkindsofmarkersfordifferentcategoriesofearthquakes.
Writecodetooverridemethodsinbaseclasses.
Writeanabstractclassthatimplementssomemethodsandleavesothersabstract.
UsePGraphicsmethodstodrawshapes.
Help Center

Introduction

Inthepartoftheprojectyoucompletedinmodule3,youwroteallofyourstylingcodefortheearthquakemarkersinthesetupmethod(orahelpermethod,which
youthencalledfromthesetupmethod).Nowthatyouvelearnedaboutinheritance,youwillusethepowerofclasshierarchiestoorganizeandimproveyourcode
whilealsoaddingnewfeatures.
Theimpactofanearthquakedependsonmanyfactors,includingwhethertheepicenterisoverlandorintheocean.Yourclasshierarchywillallowyouto
customizetheearthquakemarkerforthesedifferentkindsofearthquakes.Youwillwritecodeinfourdifferentnewclasses:anabstractclassnamed
EarthquakeMarkerandtwoclassesextendingit:LandQuakeMarkerandOceanQuakeMarker,aswellasanotherclassCityMarker.
Ineachoftheseclasses,youwilloverridethedraw()method.ThismethodisexecutedautomaticallybytheProcessingPAppletinaloopforeachofthemarkers
youcreate.

Resourcestohaveopen
InthisassignmentwewillagainexpectyoutoworkwiththedocumentationforbothUnfoldingMapsandProcessing.Youshouldopentheselinksnow:
http://unfoldingmaps.org/javadoc/(https://eventing.coursera.org/api/redirectStrict/hQdF6LPxScey5uriltMm5l5bRzGT5iA
ToT8QODD2v8t2y6rdGdEnzt_Ba8fhVeaXNeBISG10Nz5xCvwMPJFWQ.u_sGiLZkmWE_ViJGxXgtuA.zmeMMXPLc4_9mH8RJz9U1pB14xWIjb92BVXEHoJ5lV
jPHlL3hBKgoRbDqC2yKJMHV6fIpKne9Rpniz6KJngtgcQs6IAy4W
t4OEYPFKy2_Tkqd9HnhwHmlhMe1K7WZyIJJsEVM_C7fnpd2ilwffdfVONg631zEf1NOoEXQTGw9Xi1f2oHgzc7EMU6iu6FO778fSqePQB6QDCOrs5ODxcyDEYdg3
9Xy3qnQc7vydAmiT9p5hI5u4HkRIkdZ7nlyQqRvGzmOa6OY8KgHzQIDov2moK0PxUfblJaCWxJZke6V4WETLvJZ4CZOnTqL34)Inparticular,theclasses
UnfoldingMap,SimplePointMarker,PointFeatureandtheMarkerinterface
https://www.processing.org/reference/
(https://eventing.coursera.org/api/redirectStrict/3fhbtjeM5JLzDQVZcIUZ6Jk2Xj4I0R5bYGxihejnC5qM_51eewMWlZsKBVfNf13PrEDPui7nbNDv8XcAMMZcSw.NFA
Uvfk_2HAzdQzMF2rDQ.KnP0BSAj1vMWx
Uut98wqE5SQfixrkU7uNYQRRs3m6rZxnWEfzC9brvGxRoRm6MIFFmE1qOSN6ccoeDU2WjkGx5RxNT87Og7vaTIRcMRGEspqBWRaZqux3fbvm4DyrfqF2N3YFR
8S0UXgiohQOdDRPhNLZDSFER8HX5gN6A0gcewR_ZHWb8Ly6BqEhtej1LUrqcS0T8JmcMQCu
tUiCJQwJxtl7ZROOxWxZqhpXIfZPFUJf6mt9sJSMbm5cRi67hHbxfoDkfRsny1SRVGY0dLRbbVDmNyLdDSTR4iIqbrsQGKCkQVI36ChkFfQzaxpJ)Inparticularthe
methods:text(),rect(),ellipse(),andfill()willcomeinhandy.
IFYOUAREWORKINGOFFLINE,youcandownloadthesedocumentationpageswhenyouhaveaninternetconnection.

Whatyouwilldo
Justlikebefore,weprovidesomeskeletoncodetogetyoustarted.Yourgoalwillbetodothefollowing:

https://www.coursera.org/learn/objectorientedjava/supplement/tDaDh/programmingassignmentinstructions

1/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

1.Findandopenthestartercode:Youwillfindthestartercodeforthispartoftheprojectinthemodule4package.Expandthemodule4packageinthepackage
explorerandyouwillsee5javafiles:EarthquakeCityMap.java,EarthquakeMarker.java,CityMarker.java,LandQuakeMarker.java,OceanQuakeMarker.java.You
canopenanyofthembydoubleclickingonthem.Makesureyouareworkingonthefilesinthemodule4packageanddon'tpeekaheadtotheother
packages.WerecommendmakingsureallotherfilesareclosedinEclipsesoyoudontgetconfusedwhichfileyouareworkingon.
Youwillalsoseeafilenamedcitydata.jsoninthedatafolder(atthesamelevelasthesrcfolder).Youdonthavetomodifythatfile,butifyourfavoritecityisnot
there,youcanadditbyeditingthefile.Justbesuretomatchtheformatanddataoftheothercitiesexactly!
2.Tracethestartercode,predictwhathappenswhenyourunit,andthenrunit.IFYOUAREWORKINGOFFLINE:Dontforgettochangethevalueofthe
offlinevariabletotrue,otherwiseyouwillgetanerror.NoticethatthefileEarthquakeCityMap.javaimplementsmostofthefunctionalitythatyouworkedoninthe
programmingassignmentformodule3,butit'snotexactlythesame.Areyousurprisedbywhathappens(ordoesn'thappen)whenyourunit?
Hintforpart2:Wellaskyouaboutthisbehaviorontheendofmoduleassessmentsoyoumightwanttomakeanoteofwhatsgoingonandwhy.
3.ImplementtheisLand(Featureearthquake)methodinEarthquakeCityMap.Thismethodshouldreturntrueifthelocationoftheinputearthquakeisonland.
Itshouldalsosetthe"country"propertyontheLandMarkertothecountrywheretheearthquakeoccurred.Otherwise,thelocationisintheoceanandthemethod
shouldreturnfalse.Youwilltestthismethodonceyouhaveimplementedthenextmethod.
Hintforpart3:Alocationisonlandifitislocatedin*some*country.So,youcanloopthroughallcountriesandcheckifthelocationisinanyoneofthem.Youcan
(andshould)usethehelpermethodisInCountry()giveninthefile,whichtakescareofalotoftheworkofisLandforyou,includingsettingthe"country"propertyof
theearthquakePointFeature.
4.ImplementtheprintQuakes()methodinEarthquakeCityMap.ThismethodshoulduseSystem.out.println()tolisteachcountryforwhichtherewas1ormore
earthquakesandthenumberofearthquakesdetectedinthatcountry.Thenitshouldprintoutthenumberofquakesthatweredetectedintheocean.Notethatthis
methodisnottrivial.Youwillhavetocalculatethenumberofearthquakespercountryfromtheinformationyouhaveavailable.Asanaside:Ifyouarerunningthe
appletwithalargeearthquakefile/feed(e.g.1.0+Pastweekor30days),youmightfindthatprintQuakestakesalongtimetorun.Feelfreetocommentoutthecall
toprintQuakes()insetuponceyougetitworkingifyoufindthisisthecase.
Hintforpart4:Astraightforwardsolutionusesanestedloop(overthecountriesandthentheearthquakes).
5.TestisLandandprintQuakes.Tofacilitatebasictesting,wehaveincludedtwotesterinputfiles(test1.atomandtest2.atom)andtwofilesthatincludethe
expectedoutput(test1.out.txtandtest2.out.txt)foreachofthesetestfiles.Allfilesareinthedatafolder.Youwillseelinesinthestartercodeforsetup()thatyou
canuncommentinordertorunwiththetesterfiles.(Uncomment1lineatatime).Youcanruneachtestandcomparethemtothetestoutput,whichyoucanopen
ineclipsebydoubleclickingitinthepackageexplorer.Ifbothoutputsmatch,itislikelythatyouhaveimplementedbothisLandandprintQuakescorrectly.Notethat
orderandformattingdoesnothavetomatch.
6.DrawaUML(classhierarchy)diagramdescribingtheinheritancerelationshipbetweenthefollowingclasses/interfaces:
Marker
AbstractMarker
SimplePointMarker
EarthquakeMarker
LandQuakeMarker
OceanQuakeMarker
CityMarker
Youwillwanttokeepthisdiagramhandyfortheendofmoduleassessment.
Hintforpart6:Thejavadocsforforthebuiltinclasses(Marker,AbstractMarker,SimplePointMarker)willcomeinhandyhere:http://unfoldingmaps.org/javadoc/
(https://eventing.coursera.org/api/redirectStrict/hQdF6LPxScey5uriltMm5l5bRzGT5iA
ToT8QODD2v8t2y6rdGdEnzt_Ba8fhVeaXNeBISG10Nz5xCvwMPJFWQ.u_sGiLZkmWE_ViJGxXgtuA.zmeMMXPLc4_9mH8RJz9U1pB14xWIjb92BVXEHoJ5lV
jPHlL3hBKgoRbDqC2yKJMHV6fIpKne9Rpniz6KJngtgcQs6IAy4W
t4OEYPFKy2_Tkqd9HnhwHmlhMe1K7WZyIJJsEVM_C7fnpd2ilwffdfVONg631zEf1NOoEXQTGw9Xi1f2oHgzc7EMU6iu6FO778fSqePQB6QDCOrs5ODxcyDEYdg39X
y3qnQc7vydAmiT9p5hI5u4HkRIkdZ7nlyQqRvGzmOa6OY8KgHzQIDov2moK0PxUfblJaCWxJZke6V4WETLvJZ4CZOnTqL34)thenclickontheclassesyoure
interestedininthelistontheleft.
7.Completethemethoddefinitionforthedraw()methodintheCityMarkerclass.Wesuggestyouusetrianglestorepresentcities,butofcoursetheexact
shapeandcolorisuptoyou.Thenaddthemarkertoyourkey(whichyouwillneedtomodifyasyouchangeyourearthquakemarkers).Yourmapshouldnowlook
somethingliketheimagebelow.
Hintforpart7:BecauseyouarenolongerworkinginthePAppletclass,youwillneedtousethePGraphicsobjectfordrawing.Youcancallthesamemethodsyou
werecallingwhenyouweredrawingonthePApplet,butyoucallthemonthepgobject.Theargumentsxandyshouldbeused(andpassedintoyourgraphics
calls)asthecenteroftheMarkeryouaredrawing.Seethecommentsabovethedraw()methodforanexampleofhowtodothis.

https://www.coursera.org/learn/objectorientedjava/supplement/tDaDh/programmingassignmentinstructions

2/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

8.CompletethemethoddefinitionsforthedrawEarthquake()methodinLandQuakeMarkerandOceanQuakeMarkersothatthesizeofthemarkervariesby
itsmagnitude(largermagnitude=largermarker).Inaddition,maketheLandQuakeMarkersoneshape(wesuggestcircles)andtheOceanQuakeMarkersadifferent
shape(wesuggestsquares).Besuretocenterthematthex,ypositionpassedintodrawEarthquake.Also,theywillappearwhitefornow.ThatsOK.Donotset
theircolorindrawEarthquake.Thatwillbedoneinthenextstep.Thenaddyourmarkerstothekey.Yourmapshouldnowlooksomethingliketheimagebelow.
Makesurethereisavisualdifferencebetweenthesizeofthemarkersfordifferentmagnitudes.Hint:Youcanscaletheradiusorusethresholdstosetthesizeof
themarkers.

https://www.coursera.org/learn/objectorientedjava/supplement/tDaDh/programmingassignmentinstructions

3/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

9.CompletethemethoddefinitionforcolorDetermine()methodinEarthquakeMarkerandnoticewhereitandthemethodsfromthederivedclassesarecalled
intheEarthquakeMarkersdrawmethod.Youwillbeaskedabouttherelationshipbetweenthesemethodsonyourselfassessment.
ThecolorDetermine()methodchangesthecoloroftheearthquakemarkerdependingonwhethertheearthquakeisshallow,intermediate,ordeep,definedas
follows:
Shallowearthquakesarebetween0and70kmdeepintermediateearthquakes,70300kmdeepanddeepearthquakes,300700kmdeep.Ingeneral,the
term"deepfocusearthquakes"isappliedtoearthquakesdeeperthan70km.Allearthquakesdeeperthan70kmarelocalizedwithingreatslabsofshallow
lithospherethataresinkingintotheEarth'smantle.
Source:http://earthquake.usgs.gov/learn/topics/seismology/determining_depth.php
(https://eventing.coursera.org/api/redirectStrict/mg5U1s7am26crFL8aCz7v20mS9WNkturGc2rYHjBx6TL6yTB18nUPDv
KxBdmCoIgQTnnrlHQ6bin3h3zmPsQ.5Gv4SIze0m8ZWEwxlDAQgA.gjUODQ2U00rvWog8idRX41ithzBl8IVUxGHTKHEycIZoeyNFQqagiWjhGjk4G5L
pYjNC3yrMea40IXhagmetqU0lQjITAAuRu5n
qDlsffrqdzfdZZW1XyWdUBN2Kz8w9E2parxeu_u6E2rH3xfxGrLtX1WiEg41zrm4pIR5OlPGrlNH868KkabipKELUVvCs6uS
2lEbdQBTLNtxAZOYBRvISXQtSbzeYy3HK1KGCuxq25OhUbIPIJobKhxfvbyM2bEPSyehlr4YcrNq_H8XRtHt4H1oF_tYJXbR37
ZcXF4_sBIKWnvpS4VKEUsPldzitLJyE1y1ywJLPl95fKQkHjPto6NQmBstuCcjfDUeUzKs1OSLowQqGQV8FN4VZmWPENKNdR5bVRwUOSCQ)
Updateyourkeytoincludethisnewinformation.Yourmapshouldnowlookliketheimagebelow.
Hintforstep9:TheProcessingfill()methodsetsthecolorfortextandshapes.Donotusethecolor()method.

10.(Optional)ModifythedrawmethodsothatitdrawsanXoverallearthquakemarkerswhoseearthquakeshaveoccurredinthelastday.Hint:
EarthquakeMarkershaveanageproperty,andthevalueofthispropertycanbe:PastHour,PastDay,PastWeekorPastMonth.
Updateyourkeytoincludethisnewinformation.Yourmapshouldlooklikethis:

Yourealsowelcometoaddanyotherextensionsyouareinterestedin.Asusual,weencouragecreativity.
Congratulationsonfinishingthispartoftheproject!

https://www.coursera.org/learn/objectorientedjava/supplement/tDaDh/programmingassignmentinstructions

4/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

(/learn/objectorientedjava/lecture/E8OXw/projectmodule

(/learn/objectorientedjava/exam/5nJfE/programming

4programmingassignmentwalkthrough)
assignmentquizdoprogrammingassignmentfirst)
(https://accounts.coursera.org/i/zendesk/courserahelp?return_to=https://learner.coursera.help/hc)

https://www.coursera.org/learn/objectorientedjava/supplement/tDaDh/programmingassignmentinstructions

5/5

Anda mungkin juga menyukai