首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
辅导 program、java程序语言讲解
Object-Oriented Programming
Resit Coursework
This assignment involves the development of Java classes and a program to support analysis of earthquake
data compiled by the United States Geological Survey. We have provided three example datasets that you
can use to test your solution.
1 Preparation
A Zip archive containing the ffles for the assignment is provided in Minerva. When you unzip it, you should
see three ffles of earthquake data, along with four .java ffles. One of these, QuakeException.java, is
complete and ready for you to use; the other three ffles containing empty Java classes.
There are ‘To Do’ comments inside the classes that summarise the code that you need to write, and detailed
step-by-step instructions are provided below.
Before you begin programming, take some time to study the sample data. You can use a spreadsheet
application to do this. Each row in the dataset represents a single earthquake. The different columns
represent various parameters measured for an earthquake. You don’t need to know what most of these are,
although further details can be found at the USGS Earthquake Hazards Program website if you are interested.
The only columns relevant to this assignment are: latitude, longitude, depth and magnitude.
Note that fflenames consist of two parts: a severity level (often expressed in terms of earthquake magnitude)
and a time period. The two parts are separated by the underscore character. Thus, 2.5_day.csv contains
details of earthquakes of magnitude 2.5 or greater, recorded over a single day; 4.5_week.csv records
earthquakes of magnitude 4.5 or greater, over a one-week period; and significant_month.csv records
‘signiffcant’ earthquakes recorded during a one-month period.
2 Quake Class
This class encapsulates the details a single earthquake.
1. Edit Quake.java in a text editor. Add to the class ffelds that represent the latitude, longitude, depth
and magnitude of an earthquake.
2. Create a constructor for Quake that takes a single String parameter. This string represents all of the
data provided by the USGS for a single earthquake, with each value separated from the others by
commas. To see real examples of what this string looks like, open one of the data ffles in a text editor
(not in a spreadsheet), and examine any of the lines after the ffrst.
Note: you can use a method of the String class to help you implement this.
Your constructor should perform some basic validation, checking that latitude is within the allowed
range of −90.0
◦
to 90.0
◦
, and that longitude is within the allowed range of −180.0
◦
to 180.0
◦
. You
should throw an instance of QuakeException, containing an appropriate error message, if latitude or
longitude are invalid.
3. Write simple ‘getter’ methods for each of the ffelds. These methods should simply return the values
of the ffelds.
4. Write a toString method for Quake. This should generate and return a string representation of
the Quake object. The string should contain magnitude, depth, latitude and longitude, in that order,
formatted like this example:
M5.0, 12.6 km, (35.4975°, 141.0217°)
Note: the ‘degrees’ symbol can be generated with the Unicode escape sequence \u00b0.
As you complete each step of implementing this class, remove the corresponding ‘To Do’ comment and
check that your code compiles.
Once you’ve written the constructor and getter methods, you can test them by writing a small program that
creates a Quake object from a string. You can use one of the lines from the given data ffles as the string.
1IMPORTANT: You should make sure that the Quake class is working as expected before moving on to
the other class or the program that uses the classes.
3 QuakeDataset Class
This class represents an entire dataset containing the details of multiple earthquakes.
1. Edit QuakeDataset.java. Add to the class a ffeld that can represent a collection of Quake objects.
There are various options open to you here, some of which will be easier to use and more ffexible than
others. Make sure that the ffeld is initialized properly—either at the point of deffnition or by writing
a constructor.
Note that when a QuakeDataset object is created, it should represent an ‘empty’ dataset—ready to
accept data, but not yet containing any data.
2. Now write a method named readData in QuakeDataset. This method should accept two String
parameters, representing the severity level and time period for a ffle of earthquake data.
Note that the allowed values for severity level are significant, 4.5, 2.5, 1.0 and all. The
allowed values for time period are hour, day, week and month. You should throw an instance of
QuakeException if the supplied parameter values do not meet these requirements.
The readData method should
• Read earthquake data from the relevant data ffle
• Turn each line of data into a Quake object
• Store this Quake object in the ffeld provided for this purpose
The name of the data ffle should be determined from the severity level and time period parameters:
e.g., if severity is "4.5" and period is "week", then 4.5_week.csv should be used.
The readData method should NOT intercept any exceptions that might occur during the process of
reading from the CSV ffle.
3. Write a method named size that returns the number of Quake objects currently stored.
4. Write a method named get that returns the Quake object at a speciffc position. Position should be
supplied as an int parameter and should be zero-based: i.e., calling get with an argument of 0 should
return the ffrst Quake object in the dataset.
5. Write a method to ffnd and return the Quake object representing the strongest (maximum magnitude)
earthquake in the dataset. If there are multiple candidates, the ffrst one should be returned by the
method.
6. Write a method to ffnd and return the Quake object representing the shallowest (minimum depth)
earthquake in the dataset. Again, in the case of multiple candidates, the ffrst one should be returned
by the method.
7. Finally, write a method that prints out details of each Quake object, one quake per line. You should
exploit the toString method deffned in Quake for this.
As with Quake, you should remove the relevant ‘To Do’ comments as you implement each method, and you
should ffx any compilation errors before moving on to the next step.
You will need to make sure that your QuakeDataset class is reasonably robust. The get method and the
methods to ffnd the strongest, weakest, deepest and shallowest earthquakes should all throw an instance
of QuakeException if there are no Quake objects currently stored in the QuakeDataset object. The get
method should throw an instance of QuakeException if the supplied position parameter is invalid.
4 QuakeInfo Program
Edit QuakeInfo.java. Inside the main method of the class, write the code indicated by the ‘To Do’
comments, removing the comments as you go. The ffnished program should print this and then terminate if
it is run without two command line arguments:
Usage: java QuakeInfo
2If the program is run with two arguments but one or both are invalid, it should catch the resulting exception
and display the associated error message, then terminate.
If the program is run with two valid arguments, and if a valid CSV ffle corresponding to these arguments
exists, the program should generate output like this:
7 quakes in dataset
M6.1, 54.0 km, (-21.9342°, -70.3404°)
M6.2, 96.8 km, (-22.1960°, -68.4984°)
M7.0, 10.0 km, (17.5601°, 120.8011°)
M5.4, 10.0 km, (26.9092°, 55.2149°)
M6.4, 10.0 km, (-44.5986°, -79.7623°)
M6.8, 10.0 km, (-22.6455°, -114.2227°)
M4.7, 51.1 km, (60.9805°, -150.9365°)
Shallowest : M7.0, 10.0 km, (17.5601°, 120.8011°)
Strongest : M7.0, 10.0 km, (17.5601°, 120.8011°)
5 Submission
Create a Zip archive containing all of .java and .csv ffles. Submit this Zip archive via the link provided
in Minerva.
The deadline for submission will be advertised in Minerva.
3
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
讲解 econ1202 – quantitativ...
2024-11-22
辅导 msds 490: healthcare an...
2024-11-22
讲解 civl 326 geotechnical d...
2024-11-22
辅导 term paper medicine whe...
2024-11-22
讲解 eng3004 course work辅导...
2024-11-22
讲解 ee512: stochastic proce...
2024-11-22
辅导 geog100 ol01 - fall 202...
2024-11-22
辅导 st5226: spatial statist...
2024-11-22
讲解 ece 101a engineering el...
2024-11-22
讲解 database development an...
2024-11-22
讲解 comp3134 business intel...
2024-11-22
讲解 practice exam 2, math 3...
2024-11-22
讲解 project 4: advanced opt...
2024-11-22
辅导 38003 organisational be...
2024-11-22
辅导 economic growth调试spss
2024-11-22
辅导 ee512: stochastic proce...
2024-11-22
讲解 eesb04 "principles of h...
2024-11-22
辅导 am2060 final assignment...
2024-11-22
辅导 acfim0035 fundamentals ...
2024-11-22
辅导 stat 612 (fall 2024) ho...
2024-11-22
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!