Question: 1 . Add this assignment to your CS 1 4 5 0 project 2 . Create a new Java class called LastNameFirstNameAssignment 2 ( in
Add this assignment to your CS project Create a new Java class called LastNameFirstNameAssignmentin Eclipse: File New Class Please place all classes in one Java file. This makes the graders life and my life easier so thank you! Follow CS Programming Assignments Policy" Write a test program ie main that:a Opens the test file Adventures.txt for reading. b Creates a polymorphic array to store the adventures. i The st value in the file indicates how big to make the array # of adventures ii Use a regular array, DO NOT use an array list. c Fill the array with adventure objects.i For each line in the file: Read the:a Type of adventure Zipline Snorkel, Helicopterb Timec. Price for the adventure Create the specific adventure objecta. Note that type indicates what kind of object to create Place the adventure object into the polymorphic adventures array. d AFTER all lines in the file have been read and all adventure objects are in the array:i Iterate through the adventures array and for each adventure display its: Type, time, price, and description in a nicely formatted table See output section at end of document for an example table. e Create an AdventureCompanyi. Create an adventure company object Call constructor with the specific niche set of Helicopterii. Set up the adventure company Use the setupCompany method in the AdventureCompany class Send setupCompany the polymorphic array of adventures.iii. Print the adventure company details Use the printCompanyDetails method in AdventureCompany class Test file information:a Run your code on the provided file Adventures.txtb This file is an example so DO NOT assume that your code should work for only adventures in the order specified in the file. Number of adventuresZipline Snorkel Zipline Details for each adventureHelicopter See d below for details aboutHelicopter the format for these lines.Snorkel Helicopter Snorkel cst line is an integer value representing the number of adventures in the file.d The remaining lines contain details for each adventure. The format of each line is as follows: Type Time Price Zipline Classes Adventure Class Descriptiono Class that represents a generic type of adventure.o Superclass in hierarchy. Private Data Fieldso type String representing the type of adventure zipline snorkel, helicoptero time double representing the number of hours the adventure takeso price double representing the cost of the adventure Public Methodso Constructor: public AdventureString 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 private 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. Use some generic string at this level, the specific strings are in subclasses. Zipline, Snorkel, Helicopter Subclasses Descriptiono Each class represents a specific adventure.o Each class must be a subclass of Adventure. Private Data Fieldso None Public Methodso Each subclass must have a constructor that: Creates a specific Adventure with a specific type, time, and price. Note that type is NOT sent to the constructor time and price are the only two incoming values as shown here: public Ziplinedouble time, double price Why is type not sent to constructor? Inside each specific constructor the type of adventure is known, so there is no need to send the constructor the type. For example, in the Zipline constructor, we know the type of adventure being created is a Zipline adventure so the type Zipline does not need to be passed into the constructor, instead the string Zipline can be sent to the superclass constructor along with the time and price. o Each subclass must override the description method in the Adventure class. @Overridepublic String description Use the following descriptions for each specific adventure: Adventure TypeDescriptionZiplinePut on a harness, connect to a cable, enjoy an aerial viewSnorkelUse a diving mask & breathing tube, enjoy underwater worldHelicopterWatch the world unfold from a bird's eye view AdventureCompany Descriptiono Class that represents an adventure company that specializes in only specific adventure. Private Data Fieldso niche String representing the one specific adventure this company specializes ino availableAdventures array of adventures in specific niche that are available from this company Public Methodso Constructor: public AdventureCompanyString niche Creates an adventure company that specializes in a specific niche. Initializes instance variable niche to incoming niche. o GettersSetters None o public void setupCompany Adventure adventures The adventure company specializes in specific adventure which is stored in the instance variable niche when the company is created. This method st determines how many adventures in the incoming array match the companys specific niche. Next, the method creates and fills the adventure companys array availableAdventures with adventures in the incoming array that match the adventure companys niche. o public void printCompanyDetails Displays these details for the AdventureCompany: Niche the company specializes in Number of adventures it provides Type, time, and price of each adventure it provides
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
