Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

The last photo is the text file I have built up would love a good example Im almost done but having problems 1. 2. 3.

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribedThe last photo is the text file I have built up would love a good example Im almost done but having problems
image text in transcribed
1. 2. 3. 4. Add this assignment to your CS1450 project Create a new Java class called LastNameFirstNameAssignment2 Place the above hierarchy of classes in the LastNameFirstNameAssignment2.java file Follow "CS1450 Programming Assignments Policy" 5. Write a test program (i.e. main) that: a. Opens the test file NaturalDisasters.txt for reading. b. Creates a polymorphic array to store the natural disasters. The 1st value in the file to make the array. DO NOT use an array list. c. For each line in the file i. ii. Read the type (e, h, v, etc.), strength and name of the natural disaster. Create the specific disaster object (type tells you what kind of object to create). ii. Place the disaster object into the polymorphic natural disasters array. AFTER all lines in the file have been read and all disaster objects are in the array: Name, type, strength, and rating scale in a table d. i. Iterate through the natural disasters array and for each disaster display its: 1. 2. See output section for an example table 6. Test file information: a. b. Run your code on the provided file NaturalDisasters.txt This file is an example so DO NOT assume that your code should work for only 10 disasters in the order specified in the file. Number of disasters 10 h 5 Katrina e 9.2 Good Friday Earthquake v 5 Mount St. Helens t FS Joplin Missouri v1 Mount Kilauea h 4 Michael v 3 Bogoslof Island t F5 Tri-State h 5 Andrew e 6.9 Loma Prieta Details for each disaster See (d) below for details on the format of these lines 1st line is an integer value representing the number of natural disasters in the file Remaining lines contain details for each disaster. The format is as follows: c. d. Type Strength Name h 5 Katrina Classes NaturalDisaster Class o Class that represents a generic natural disaster o Superclass in the hierarchy e Private Data Fields o name String representing the disaster's name o type-String representing the type of disaster (earthquake, hurricane, etc.) o strength-String representing the disaster's strength or magnitude . Public Methods o Constructor public NaturalDisaster(String name, String type, String strength) Creates a natural disaster using incoming values for name, type and strength . One for each data field- name, type and strength . No setters are needed o Getters o Setters Returns a string representing how a disaster is rated. . See measurement scale shown in table below Earthquake, Hurricane, Tornado, Volcano Subclasses o Class that represents a specific natural disaster o Each of these classes must be a subclass of NaturalDisaster Private Data Fields o None Public Methods o Each subclass MUST override the ratingScale() method in the NaturalDisaster class. public String ratingScale0) o Use the following measurement scales for each specific disaster: Disaster T Earthquake Hurricane Tornado Volcano Richter Scale: 1.0 to 9.0or greater Scaffir-Sinm Fujita Scale: FO to FS Volcanic E n Wind Scale: 1 to S Index: 0 to 8 Must Dos Must Do: .Use an array to store the natural disasters not an ArrayList. The name, type and strength must be defined only in the superclass Natural Disaster Note Strength is a string not an int or double. o lused a string because tornados are rated as F1, F2, etc.-so not just numeric value. o Read it from the file as a string and leave it as a string. o No need to turn strength into an int or double. Output If your program is using inheritance and polymorphism correctly, your output will look like the following when running against the test file NaturalDisasters.txt Disaster Name Type Strength Measurement Scale Katrina Hurricane Scaffir-Simpson Wind Scale: 1 to 5 Richter Scale:1.0 to 9.0 or greater Good Friday Earthquake Earthquake Mount St. Helens 92 Volcano Volcanic Explosivity Index: 0 to 8 Must Dos Must Do: . Use an array to store the natural disasters not an ArrayList. .The name, type and strength must be defined only in the superclass Natural Disaster Note Strength is a string not an int or double o o o used a string because tornados are rated as F1, F2, etc.- so not just numeric value. Read it from the file as a string and leave it as a string. No need to turn strength into an int or double Output If your program is using inheritance and polymorphism correctly, your output will look like the followin when running against the test file NaturalDisasters.txt Disaster Name Type Strength Measurement Scale 5 Scaffir-Simpson Wind Scale: 1 to 5 Richter Scale: 1.0 to 9.0 or greater Katrina Good Friday Earthquake Earthquake 9 Mount St. Helens Joplin Missouri Volcanic Explosivity Index: 0 to 8 Fujita Scale: FO to F5 Volcano Tornado F5 Mount Kilauea Michael Bogoslof Island Tri-State Andrew Loma Prieta Volcano Hurricane Volcano Tornado Volcanic Explosivity Index: 0 to 8 Scaffir-Simpson Wind Scale: 1 to5 Volcanic Explosivity Index: 0 to 8 F5 Fujita Scale: FO to F5 5 Scaffir-Simpson Wind Scale: 1 to 5 Earthquake 6.9 Richter Scale:1.0 to 9.0 or greater 10 h 5 Katrina e 9.2 Good Friday Earthquake v 5 Mount St. Helens t FS Joplin Missouri v 1 Mount Kilauea h 4 Michael v 3 Bogoslof Island t FS Tri-State h 5 Andrew e 6.9 Loma Prieta

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions