0% found this document useful (0 votes)
270 views5 pages

Week 3 Java Programming Assignment

This document provides instructions for a programming assignment involving customizing earthquake markers. Students will create a class hierarchy with an abstract EarthquakeMarker class and subclasses LandQuakeMarker, OceanQuakeMarker, and CityMarker. Each class will override the draw() method. The tasks are to 1) implement an isLand() method to determine if an earthquake occurred on land or ocean, 2) implement a printQuakes() method to output earthquake counts by country and in the ocean, and 3) test these methods using provided sample data and expected output files.

Uploaded by

nishantgaurav23
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
270 views5 pages

Week 3 Java Programming Assignment

This document provides instructions for a programming assignment involving customizing earthquake markers. Students will create a class hierarchy with an abstract EarthquakeMarker class and subclasses LandQuakeMarker, OceanQuakeMarker, and CityMarker. Each class will override the draw() method. The tasks are to 1) implement an isLand() method to determine if an earthquake occurred on land or ocean, 2) implement a printQuakes() method to output earthquake counts by country and in the ocean, and 3) test these methods using provided sample data and expected output files.

Uploaded by

nishantgaurav23
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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:[Link]
java/Module%204%20PA%[Link]
([Link]
YZWROGrmgBA0VaXmeerg.t1AdIxVzI2Ix_lIDJ73IlEd4j2EU6UsrRpC9kU1AF8AN4DlCobwefA4FnwoZlEuW5ewu6FWwLT0wmrziH8E
AmKeRdNZ8Qm9ITykctmoxWfu1yDri
rXJWjA5H_4x0IJOnOlEH1AixbczO8jSSAgFUkcx_TvZ5tHHoqIOzdsDPdW3Ev9MskohuFcHZeHdRAMgZWOERnG_u9YAxtRLnTL8I9IBMBvzDfL18brNDdZ6KpxIFbL
GipN58KxWkbYioTAewIvOAXDOkWSerqxbwrpN_mCqbNNNtYBtKowslDuYE3YykJcvnDMhhfKs5dCrKAw4r0dWYGHZEXs1HUkrqQ9x2xf3SmRMt4w2TuJYELTbThC
CRgaHp5_Nyr1Q8g24p47gy5jdgdkRVQ0Wy
ewYCIO5JCpi5XUihiobVO_S48mrdXcM9vTZNGrHdUGr3qiX8MHREczvOVb0Qt61BULRjbqAAVC6n2A62OoDx5BCh8v_2fFvFXrzjDLsyLrXiB0_)
Justlikeinmodule3,[Link],[Link],afteryou
[Link],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,[Link]
[Link]:anabstractclassnamed
EarthquakeMarkerandtwoclassesextendingit:LandQuakeMarkerandOceanQuakeMarker,aswellasanotherclassCityMarker.
Ineachoftheseclasses,youwilloverridethedraw()[Link]
youcreate.

Resourcestohaveopen
[Link]:
[Link]
ToT8QODD2v8t2y6rdGdEnzt_Ba8fhVeaXNeBISG10Nz5xCvwMPJFWQ.u_sGiLZkmWE_ViJGxXgtuA.zmeMMXPLc4_9mH8RJz9U1pB14xWIjb92BVXEHoJ5lV
jPHlL3hBKgoRbDqC2yKJMHV6fIpKne9Rpniz6KJngtgcQs6IAy4W
t4OEYPFKy2_Tkqd9HnhwHmlhMe1K7WZyIJJsEVM_C7fnpd2ilwffdfVONg631zEf1NOoEXQTGw9Xi1f2oHgzc7EMU6iu6FO778fSqePQB6QDCOrs5ODxcyDEYdg3
9Xy3qnQc7vydAmiT9p5hI5u4HkRIkdZ7nlyQqRvGzmOa6OY8KgHzQIDov2moK0PxUfblJaCWxJZke6V4WETLvJZ4CZOnTqL34)Inparticular,theclasses
UnfoldingMap,SimplePointMarker,PointFeatureandtheMarkerinterface
[Link]
([Link]
Uvfk_2HAzdQzMF2rDQ.KnP0BSAj1vMWx
Uut98wqE5SQfixrkU7uNYQRRs3m6rZxnWEfzC9brvGxRoRm6MIFFmE1qOSN6ccoeDU2WjkGx5RxNT87Og7vaTIRcMRGEspqBWRaZqux3fbvm4DyrfqF2N3YFR
8S0UXgiohQOdDRPhNLZDSFER8HX5gN6A0gcewR_ZHWb8Ly6BqEhtej1LUrqcS0T8JmcMQCu
tUiCJQwJxtl7ZROOxWxZqhpXIfZPFUJf6mt9sJSMbm5cRi67hHbxfoDkfRsny1SRVGY0dLRbbVDmNyLdDSTR4iIqbrsQGKCkQVI36ChkFfQzaxpJ)Inparticularthe
methods:text(),rect(),ellipse(),andfill()willcomeinhandy.
IFYOUAREWORKINGOFFLINE,youcandownloadthesedocumentationpageswhenyouhaveaninternetconnection.

Whatyouwilldo
Justlikebefore,[Link]:

[Link]

1/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

[Link]:Youwillfindthestartercodeforthispartoftheprojectinthemodule4package.Expandthemodule4packageinthepackage
explorerandyouwillsee5javafiles:[Link],[Link],[Link],[Link],[Link]
canopenanyofthembydoubleclickingonthem.Makesureyouareworkingonthefilesinthemodule4packageanddon'tpeekaheadtotheother
[Link].
[Link](atthesamelevelasthesrcfolder).Youdonthavetomodifythatfile,butifyourfavoritecityisnot
there,[Link]!
[Link],predictwhathappenswhenyourunit,[Link]:Dontforgettochangethevalueofthe
offlinevariabletotrue,[Link]
programmingassignmentformodule3,butit'[Link](ordoesn'thappen)whenyourunit?
Hintforpart2:Wellaskyouaboutthisbehaviorontheendofmoduleassessmentsoyoumightwanttomakeanoteofwhatsgoingonandwhy.
[Link](Featureearthquake)[Link].
Itshouldalsosetthe"country"[Link],thelocationisintheoceanandthemethod
[Link].
Hintforpart3:Alocationisonlandifitislocatedin*some*[Link],[Link]
(andshould)usethehelpermethodisInCountry()giveninthefile,whichtakescareofalotoftheworkofisLandforyou,includingsettingthe"country"propertyof
theearthquakePointFeature.
[Link]()[Link]()tolisteachcountryforwhichtherewas1ormore
[Link]
[Link]:Ifyouarerunningthe
appletwithalargeearthquakefile/feed(e.g.1.0+Pastweekor30days),[Link]
toprintQuakes()insetuponceyougetitworkingifyoufindthisisthecase.
Hintforpart4:Astraightforwardsolutionusesanestedloop(overthecountriesandthentheearthquakes).
[Link],wehaveincludedtwotesterinputfiles([Link])andtwofilesthatincludethe
expectedoutput([Link])[Link]()thatyou
canuncommentinordertorunwiththetesterfiles.(Uncomment1lineatatime).Youcanruneachtestandcomparethemtothetestoutput,whichyoucanopen
[Link],[Link]
orderandformattingdoesnothavetomatch.
[Link](classhierarchy)diagramdescribingtheinheritancerelationshipbetweenthefollowingclasses/interfaces:
Marker
AbstractMarker
SimplePointMarker
EarthquakeMarker
LandQuakeMarker
OceanQuakeMarker
CityMarker
Youwillwanttokeepthisdiagramhandyfortheendofmoduleassessment.
Hintforpart6:Thejavadocsforforthebuiltinclasses(Marker,AbstractMarker,SimplePointMarker)willcomeinhandyhere:[Link]
([Link]
ToT8QODD2v8t2y6rdGdEnzt_Ba8fhVeaXNeBISG10Nz5xCvwMPJFWQ.u_sGiLZkmWE_ViJGxXgtuA.zmeMMXPLc4_9mH8RJz9U1pB14xWIjb92BVXEHoJ5lV
jPHlL3hBKgoRbDqC2yKJMHV6fIpKne9Rpniz6KJngtgcQs6IAy4W
t4OEYPFKy2_Tkqd9HnhwHmlhMe1K7WZyIJJsEVM_C7fnpd2ilwffdfVONg631zEf1NOoEXQTGw9Xi1f2oHgzc7EMU6iu6FO778fSqePQB6QDCOrs5ODxcyDEYdg39X
y3qnQc7vydAmiT9p5hI5u4HkRIkdZ7nlyQqRvGzmOa6OY8KgHzQIDov2moK0PxUfblJaCWxJZke6V4WETLvJZ4CZOnTqL34)thenclickontheclassesyoure
interestedininthelistontheleft.
[Link]()[Link],butofcoursetheexact
[Link](whichyouwillneedtomodifyasyouchangeyourearthquakemarkers).Yourmapshouldnowlook
somethingliketheimagebelow.
Hintforpart7:BecauseyouarenolongerworkinginthePAppletclass,[Link]
werecallingwhenyouweredrawingonthePApplet,[Link](andpassedintoyourgraphics
calls)[Link]()methodforanexampleofhowtodothis.

[Link]

2/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

[Link]()methodinLandQuakeMarkerandOceanQuakeMarkersothatthesizeofthemarkervariesby
itsmagnitude(largermagnitude=largermarker).Inaddition,maketheLandQuakeMarkersoneshape(wesuggestcircles)andtheOceanQuakeMarkersadifferent
shape(wesuggestsquares).Besuretocenterthematthex,[Link],[Link]
[Link].
[Link]:Youcanscaletheradiusorusethresholdstosetthesizeof
themarkers.

[Link]

3/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

[Link]()methodinEarthquakeMarkerandnoticewhereitandthemethodsfromthederivedclassesarecalled
[Link].
ThecolorDetermine()methodchangesthecoloroftheearthquakemarkerdependingonwhethertheearthquakeisshallow,intermediate,ordeep,definedas
follows:
Shallowearthquakesarebetween0and70kmdeepintermediateearthquakes,70300kmdeepanddeepearthquakes,[Link],the
term"deepfocusearthquakes"isappliedtoearthquakesdeeperthan70km.Allearthquakesdeeperthan70kmarelocalizedwithingreatslabsofshallow
lithospherethataresinkingintotheEarth'smantle.
Source:[Link]
([Link]
KxBdmCoIgQTnnrlHQ6bin3h3zmPsQ.5Gv4SIze0m8ZWEwxlDAQgA.gjUODQ2U00rvWog8idRX41ithzBl8IVUxGHTKHEycIZoeyNFQqagiWjhGjk4G5L
pYjNC3yrMea40IXhagmetqU0lQjITAAuRu5n
qDlsffrqdzfdZZW1XyWdUBN2Kz8w9E2parxeu_u6E2rH3xfxGrLtX1WiEg41zrm4pIR5OlPGrlNH868KkabipKELUVvCs6uS
2lEbdQBTLNtxAZOYBRvISXQtSbzeYy3HK1KGCuxq25OhUbIPIJobKhxfvbyM2bEPSyehlr4YcrNq_H8XRtHt4H1oF_tYJXbR37
ZcXF4_sBIKWnvpS4VKEUsPldzitLJyE1y1ywJLPl95fKQkHjPto6NQmBstuCcjfDUeUzKs1OSLowQqGQV8FN4VZmWPENKNdR5bVRwUOSCQ)
[Link].
Hintforstep9:TheProcessingfill()[Link]()method.

10.(Optional)[Link]:
EarthquakeMarkershaveanageproperty,andthevalueofthispropertycanbe:PastHour,PastDay,PastWeekorPastMonth.
[Link]:

[Link],weencouragecreativity.
Congratulationsonfinishingthispartoftheproject!

[Link]

4/5

10/24/2015

ProgrammingAssignmentInstructions|Coursera

(/learn/objectorientedjava/lecture/E8OXw/projectmodule

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

4programmingassignmentwalkthrough)
assignmentquizdoprogrammingassignmentfirst)
([Link]

[Link]

5/5

You might also like