Question: Quake.java: import java.util.*; class Quake { long time; double mag; String magType; int tsunami; public Quake(long time, double mag, String magType) { this.time = time;

Quake.java:

import java.util.*;

class Quake {

long time;

double mag;

String magType;

int tsunami;

public Quake(long time, double mag, String magType) {

this.time = time;

this.mag = mag;

this.magType = magType;

}

public Quake(long time, double mag, String magType, int tsunami) {

this.time = time;

this.mag = mag;

this.magType = magType;

this.tsunami = tsunami;

}

public String toString() {

Date date = new Date(time); // this is a built in utility function

to covert the date

return mag + " quake at time " + date.toString();

}

public double getMagnitude() {

return mag;

}

public int getTsunami() {

return tsunami;

}

public long minutesAgo() {

long epoch = System.currentTimeMillis();

long diffMill = epoch - time;

long diffMin = diffMill/(1000*60);

return diffMin;

}

public void printTimeInfo() {

Date date = new Date(time); // this is a built in utility function

to covert the date

System.out.println(date);

}

}

QuakeDemo.java:

import core.data.*;

public class QuakeDemo {

public static void main(String[] args) {

DataSource ds =

DataSource.connect("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summa

ry/all_day.geojson");

ds.setCacheTimeout(300);

ds.load();

// ds.printUsageString();

Quake[] todaysQuakes = ds.fetchArray("Quake",

"features/properties/time",

"features/properties/mag",

"features/properties/magType",

"features/properties/tsunami");

for (int i = 0; i

System.out.println(todaysQuakes[i]);

}

double max = 0;

Quake big = null;

for (int i = 0; i

if (todaysQuakes[i].getMagnitude() > max) {

big = todaysQuakes[i];

max = todaysQuakes[i].getMagnitude();

}

}

System.out.println("Biggest recent quake: " + big);

big.printTimeInfo();

int count = 0;

for (int i = 0; i

count = count + todaysQuakes[i].getTsunami();

}

System.out.println(count + " possible tsunami events out of "

+ todaysQuakes.length);

}

}

TASK:

Quake.java: import java.util.*; class Quake { long time; double mag; String magType;

.Add another String attribute for place into the class (and both constructors) Add an accessor for this attribute Assuming that place is the last item in your accessor call you will need to modify the array declaration in main to add this field as follows: Quake[ todaysQuakes-ds.fetchArray ("Quake", "features/properties/time", "features/properties/mag", "features/properties/magType", "features/properties/tsunami", "features/properties/place") Add code to use the accessor to print the locations of the earthquakes in the loop. Choose one more feature from the properties list and incorporate it into the class / demo progranm https://earthquake.usgs.govlearthquakes/feed/v1.olgeojson.php

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!