Answered step by step
Verified Expert Solution
Question
1 Approved Answer
So I am pretty much done i am just having issues with reading my file and i keep getting errors on my classes any help?
So I am pretty much done i am just having issues with reading my file and i keep getting errors on my classes any help?
Also the last picture is the txt file i am using to test any help would be amazing thank you!! also I am using java
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 indicates how big 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). Place the disaster object into the polymorphic natural disasters array. iii. d. AFTER all lines in the file have been read and all disaster objects are in the array: i. Iterate through the natural disasters array and for each disaster display its: 1. 2. Name, type, strength, and rating scale in a table See output section for an example table 6. Test file information: 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 a. b. h 5 Katrina e 9.2 Good Friday Earthquake.. v 5 Mount St. Helens t F5 Joplin Missouri v 1 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 c. d. 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 Type Strength Name h 5 Katrina Classes NaturalDisaster Class Description o Class that represents a generic natural disaster o Superclass in the hierarchy 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 o ratingScale() Returns a string representing how a disaster is rated See measurement scale shown in table below " Earthquake, Hurricane, Tornado, Volcano Subclasses * Description 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 @Override public String ratingScale) o Use the following measurement scales for each specific disaster: Disaster Type Earthquake Hurricane Tornado Volcano Type Measurement Scale Richter Scale: 1.0 to 9.0 or greater Scaffir-Simpson Wind Scale: 1 to 5 Fujita Scale: FO to F5 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 used 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 Output- Example Disaster Name Type Strength Measurement Scale Katrina Good Friday Earthquake Earthquake Mount St. Helens Joplin Missouri Hurricane Scaffir-Simpson Wind Scale: 1 to 5 Richter Scale: 1.0 to 9.0 or greater Volcanic Explosivity Index: 0 to 8 Fujita Scale: F0 to F5 9.2 Volcando Tornado F5 Mount Kilauea Michael Bogoslof Island Tri-State Andrew Loma Prieta Volcando Hurricane Volcano Tornado Hurricane Earthquake 4 3 F5 5 6.9 Volcanic Explosivity Index: 0 to 8 Scaffir-Simpson Wind Scale: 1 to 5 Volcanic Explosivity Index: 0 to 8 Fujita Scale: FO to F5 Scaffir-Simpson Wind Scale: 1 to 5 Richter Scale: 1.0 to 9.0 or greater h 5 Katrina e 9.2 Good Friday Earthquake v 5 Mount St. Helens t F5 Joplin Missouri v 1 Mount Kilauea h 4 Michael v 3 Bogoslof Island t F5 Tri-State h 5 Andrew e 6.9 Loma PrietaStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started