Answered step by step
Verified Expert Solution
Question
1 Approved Answer
could you please help me out on this one? I did write the code but the output is not as the picture below. The below
could you please help me out on this one? I did write the code but the output is not as the picture below. The below pic is the requirement:
thank you!
CS 1450 Data Structures and Algorithms Assignment \#2 Purpose: Review of classes, objects, inheritance and polymorphism. Effort: Individual Points: 4.5 Deliverables: Upload a .zip file with ONLY your source code (one .java file) along with your design notebook in a document file to Canvas by due date. (no late assignments accepted) Assignment Description This assignment is an opportunity to review objects, inheritance and polymorphism. Write code that creates the following hierarchy. Please place all classes in one Java file. *** (This makes the grader's life easier!) Your code will perform actions on these objects and display information proving you have properly used inheritance and polymorphism. Use the provided file SeaTurtles.txt to test your code. Specifications 1. Add this assignment to your CS1450 project 2. Create a new Java class called LastNameFirstNameAssignment2 3. Place the above hierarchy of classes in the LastNameFirstNameAssignment2.java file 4. Follow "CS1450 Programming Assignments Policy" 5. Write a test program (i.e. main) that: a. Opens the test file SeaTurtles.txt for reading. b. Creates a polymorphic array to store the sea turtles. The 141 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. Read the type (Ih, gt, etc.), days tracked, miles travels, and name of the turtle. ii. Create the specific turtle object (type tells you what kind of object to create). iii. Place the turtle object into the polymorphic sea turtles' array. d. AFTER all lines in the file have been read and all sea turtle objects are in the array: i. Iterate through the sea turtles array and for each turtle display its: 1. Name, type, days tracked, miles traveled, threat to survival in a table 2. See output section for an example table 6. Test file information: a. Run your code on the provided file SeaTurtles.txt b. This file is an example so DO NOT assume that your code should work for only 9 turtles in the order specified in the file. 6. Test file information: a. Run your code on the provided file SeaTurtles.txt b. This file is an example so DO NOT assume that your code should work for only 9 turtles in the order specified in the file. c. 1st line is an integer value representing the number of sea turtles in the file. d. Remaining lines contain details for each sea turtle. The format is as follows: Classes SeaTurtle Class - Description Class that represents a generic sea turtle. Superclass in the hierarchy. - Private Data Fields name - String representing the sea turtle's name type - String representing the type of sea turtle (loggerhead, hawksbill, etc.) daysTracked integer representing the number of days the turtle was tracked milesTraveled - double representing number of miles the turtle traveled while tracked - Public Methods - Constructor public SeaTurtle(String name, String type, int daysTracked, double milesTraveled) - Creates sea turtle using incoming values for name, type, daysTracked, milestraveled Getters - One for each data field - name, type, daysTracked, milesTraveled Setters - No setters are needed (this is being done on purpose so do not include setters) threatsToSurvival() - Returns a string representing what threatens the survival of the turtle. - See threats to survival shown in table below. Loggerhead, GreenTurtle, Hawksbill, Leatherback Subclasses - Description Each class represents a specific sea turtle. Each of these classes must be a subclass of SeaTurtle. Loggerhead, GreenTurtle, Hawksbill, Leatherback Subclasses - Description Each class represents a specific sea turtle. Each of these classes must be a subclass of SeaTurtle. - Private Data Fields None - Public Methods - Constructors - Incoming values are only name, daysTracked, and milesTraveled. - Inside each constructor the type of turtle is known, so type is not pass in public Loggerhead(String name, int daystracked, double milestraveled) Each subclass must override the threatsToSurvival() method in the SeaTurtle class. @override public String threatsToSurvival() - Use the following threats to survival for each specific turtle: Must Dos and Tips Must Do: - Use an array to store the sea turtles not an ArrayList. - Name, type, daysTracked, and milesTraveled must be defined only in the superclass SeaTurtle. - These are common for all sea turtles so we define them only in superclass Must Not: - Do not include setters in the SeaTurtle superclass. Note - The turtles I included in this assignment are real turtles that were tracked. - Go to https://conserveturtles.org/sea-turtle-tracking-active-sea-turtles/ to see the migration map for these turtles. - Go to https://conserveturtles.org/sea-turtle-tracking-tour-de-turtles-sea-turtle-migrationmarathon/ to read about Tour De Turtles. Tip: Build the classes first - Before writing the code in main, build as much of the classes as possible If your program is using inheritance and polymorphism correctly, your output will look like the following when running against the test file SeaTurtles.txtStep 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