in java, the last picture is adventures.txt thank you
Assignment Description This assignment is an opportunity to review objects, inheritance, and polymorphism. You will create the following hierarchy in your code: = Adventure Zipline Snorkel Helicopter Your code will perform actions on these objects and display information proving you have properly used inheritance and polymorphism. Use the provided file Adventures.txt to test your code Specifications Read these specifications to get an overview of assignment. When writing code, first create the classes. 1. Add this assignment to your CS1450 project 2. Create a new Java class called LastNameFirstNameAssignment2 (in Eclipse: File -> New -> Class) 3. Create the above hierarchy of classes in the LastNameFirstNameAssignment2.java file 4. Please place all classes in one Java file. This makes the grader's life and my life easier. 5. Follow "CS1450 Programming Assignments Policy" 6. Write a test program (i.e. main) that: a. Opens the test file Adventures.txt for reading b. Creates a polymorphic array to store the adventures. The 1" value in the file indicates how big to make the array. Be sure to use a regular array, NOT an array list. c. For each line in the file: I. Read the type (Zipline, Snorkel, Helicopter), time, and price of the adventure. it. Create specific adventure object (the type indicates the kind of object to create). ili. Place the adventure object into the polymorphic adventures array. d. AFTER all lines in the file have been read and all adventure objects are ready 11 d. AFTER all lines in the file have been read and all adventure objects are in the array: 1.Iterate through the adventures array and for each adventure display its type, time, price, and description in a table. i. See output section at end of document for an example table e. Create an Adventure Company object 1. Create an adventure company 1. Call constructor with the specific niche set of "Snorkel" li. Setup the adventure company 1. Use the adventures in polymorphic array that match the company's niche. 2. Use the setup Company method in the Adventure Company class ili. Print the adventure company details 1. Use the print Company Details method in Adventure Company class 7. Test file information: a. Run your code on the provided file Adventures.txt b. This file is an example so DO NOT assume that your code should work for only 8 adventures in the order specified in the file. 8 -Number of adventures Zipline 4.5 210 Snorkel 4.25 190 Zipline : 225 Details for each adventure Helicopter 6 420 See td) below for details about Helicopter 2.25 350 the format for these lines. Snorkel 4.5 135 Helicopter 4.25 599 Snorkel 4 260 c. 1" line is an integer value representing the number of adventures in the file. d. Remaining lines contain details for each adventure. The format of each line is as follows: Type Time Price Zipline 210 Type Time Price Zipline 4.5 210 Classes Adventure Class Description Class that represents a generic type of adventure. o Superclass in the hierarchy. Private Data Fields o type - String representing the type of adventure (zipline, snorkel, helicopter) o time - double representing the number of hours the adventure takes price - double representing the cost of the adventure Public Methods o Constructor: public Adventure(String type, double time, double price) Creates an adventure by initializing instance variables type, time, and price to the incoming values for type, time, and price. o Getters One for each instance variable-type, time, price o Setters . No setters are needed (this is being done on purpose so do not include setters) o public String description() Returns a string that describes the adventure. Zipline, Snorkel, Helicopter Subclasses Description Each class represents a specific adventure. o Each class must be a subclass of Adventure . Private Data Fields o None Public Methods Constructors The time and price are the only two incoming values. Inside each constructor the type of adventure is known. So pe 5 not passed in . Private Data Fields o None Public Methods Constructors The time and price are the only two incoming values. Inside each constructor the type of adventure is known, so type is not passed in. . That is in the Zipline constructor, you know that the type of adventure being created is a Zipline adventure. public Zipline( double time, double price) Each subclass must override the description() method in the Adventure class. @Override public String description() Use the following descriptions for each specific adventure: Adventure Type Description Zipline Put on a harness, connect Snorkel Use a diving mask & Helicopter Watch the world unfo Adventure Company Description Class that represents an adventure company that provides only 1 specific adventure. Private Data Fields o niche - String representing the one specific adventure this company specializes in availableAdventures - array of specific adventures that are available from this company Public Methods Constructor public Adventure Company/String niche) Creates an adventure company that specializes in a specific niche. Initializes instance variable niche to incoming niche Getters/Setters None Adventure Type Zipline Snorkel Helicopter Description Put on a harness, connect to a cable, enjoy an aerial view Use a diving mask & breathing tube, enjoy underwater world Watch the world unfold from a bird's eye view 1:21 that are available from this company Public Methods Constructor public Adventure Company(String niche) Creates an adventure company that specializes in a specific niche. Initializes instance variable niche to incoming niche Getters/Setters None public void setup Company (Adventurell adventures) The adventure company specializes in 1 specific adventure which is stored in the instance variable niche when the company is created. This method 1" determines how many adventures in the incoming array that match its niche. Next, the method creates and fills the adventure company's array (availableAdventures) with the adventures in the incoming array that match its niche. o public void printCompany Details) Displays these details: Niche the company specializes in Number of adventures it provides Type, time, and price of each adventure it provides Must Dos and Tips Must Do: General Use an array to store the adventures not an ArrayList. Type, time, and price instance variables must be defined only in the superclass Adventure. This is done because these values are common for all adventures. In each class, all instance variables must be private. Provide pseudocode for main. Pseudocode for classes is not necessary al 1:21 Must Dos and Tips Must Do: General Use an array to store the adventures not an ArrayList. Type, time, and price instance variables must be defined only in the superclass Adventure. This is done because these values are common for all adventures. In each class, all instance variables must be private Provide pseudocode for main. Pseudocode for classes is not necessary Must Not Do: . Do not include setters in the Adventure superclass. Tip: Build the classes first . Before writing the code in main, build as much of the classes as possible. You need to create at least a skeleton of each class before you can write the code in main to create the adventures. Tip: Reading from files When reading from a file, use the methods on the Scanner class to obtain the different pieces of data in the file. . DO NOT read one entire line and then parse the line to get the different values The Scanner methods will do the parsing for you. If you need a review about the Scanner methods next and nextLine, see notes at the end of lecture 13. Tips: Exceptions You may have learned about try/catch blocks in your Java class. Exceptions are important, but they add complexity to code, which is unnecessary at this point. To eliminate the need for added complexity and the use of try/catch blocks, have main throw an IOException public static void main(String[] args) throws IOException { Tip: . Please place all classes into one Java file. To do so, the layout should be as follows: = 1:214 Tip: . Please place all classes into one Java file. To do so, the layout should be as follows: public class Assignment2 { public static void main(String[] args) throws IOException // Code to create array of adventures and read adventures from the file }//main } Assignment2 Note this is the end of your assignment 2 New classes go AFTER this point New classes do not include public keyword class Adventure // Details for the adventure class go here } // Adventure class Zipline extends Adventure { // Detalls for the zipline class go here } // Zipline // Add remaining classes here Output If your program is using inheritance and polymorphism correctly, your output will look like the following when running against the test file Adventures.txt Output - Example Type Time Price Description = Zipline 4.50 $21e.ee Put on a harness, connect to a cable, enjoy an aerial view Snorkel 4.25 $190.se Use a diving mask & breathing tube, enjoy underwater world Zipline 5.ee $225.ee Put on a harness, connect to a cable, enjoy an aerial view Helicopter 6.80 $420.80 Watch the world unfold from a bird Walt 25 225 ht 1:217 } // Adventure class Zipline extends Adventure // Details for the zipline class go here } // Zipline // Add remaining classes here Output If your program is using inheritan and polymorphism correctly, your output will look like the following when running against the test file Adventures.txt Output - Example Type Time Price Description Zipline 4.50 $210.89 Put on a harness, connect to a cable, enjoy an aerial view Snorkel 4.25 $190.00 Use a diving mask & breathing tube, enjoy underwater world Zipline 5.80 $225.00 Put on a harness, connect to a cable, enjoy an aerial view Helicopter 6.00 $420.00 Watch the world unfold from a bird's eye view Helicopter 2.25 $350.ee Watch the world unfold from a bird's eye view Snorkel 4.50 $135.ee Use a diving mask & breathing tube, enjoy underwater world Helicopter 4.25 $599.00 Watch the world unfold from a bird's eye view Snorkel 4.80 $260.00 Use a diving mask & breathing tube, enjoy underwater world CS1450 Adventures Company's niche: Snorkel adventures Adventures available: 3 Snorkel ... 4.25 hours --- $190.ee Snorkel ... 4.50 hours $135.ee Snorkel --- 4.89 hours --- $260.ee = 8 Zipline 4.5 210 Snorkel 4.25 190 Zipline 5 225 Helicopter 6 420 Helicopter 2.25 350 Snorkel 4.5 135 Helicopter 4.25 599 Snorkel 4 260 Dashboard Calendar To Do Notifications Inbox