Hello! I have an overstack error, I’m not too sure how to fix it….

Question Answered step-by-step Hello! I have an overstack error, I’m not too sure how to fix it…. Hello! I have an overstack error, I’m not too sure how to fix it.  Instructions/Expected outcome:Image transcription textThe starter files Astronaut.java andMarsCrew.java represent the crew of amission to Mars. MarsCr… Show more… Show moreImage transcription text1/ // Expected program outputs 11- // Notethat your codes may be tested with moretestcaes when needed / / for th… Show more… Show more Here’s my code: class1: the overstack error is occurring in this classimport java.util.*;// MarsCrew must extend Object. // 0 points if MarsCrew does not extend Objectpublic class MarsCrew extends Object implements Iterable{ private TreeSet experienced; // Hashset is okay for this question private TreeSet inexperienced; // Hashset is okay for this question public MarsCrew() { experienced = new TreeSet(); inexperienced = new TreeSet (); } // If this crew does not already contain an astronaut that // is deep-equal to a, then add a to this crew. public void add(Astronaut a) { // xxx to be finished … MarsCrew crew = genCrew(); crew.add(a); } // Return true if this crew contains an astronaut that is deep-equal to a. public boolean contains(Astronaut a) { // xxx to be finished … MarsCrew crew = genCrew(); return crew.contains(a); } // Return an array list of all astronauts, sorted first by name, // then by height, and then by mass. public ArrayList getSorted() { // xxx to be finished … TreeSet crew = new TreeSet(); return new ArrayList(crew); } public void listSorted () { System.out.println(); String s =”List crew without considering their experiences.”; System.out.println( s ); ArrayList arr = getSorted() ; for (Astronaut x:arr) System.out.println( x ); System.out.println(); } public void listByExperience ( ) { System.out.println(); System.out.println( “List crew by their experiences!”); for (Astronaut a: this) { // enhanced for-loop System.out.println(a); } } @Override public Iterator iterator() { // xxx to be finished return getSorted().iterator(); } public static MarsCrew genCrew() { MarsCrew crew= new MarsCrew (); String[] names = {“Cardman,Zena”, “Rubins,Kathleen”, “Hopkins,Michael”, “Glenn,John”, “Shepard,Alan”} ; float[] h = {68, 70, 71, 68, 72}; double[] w = {180,150, 170, 155, 177}; int [] yr = { 2017, 2009, 2009, 1959, 1969}; int n = names.length ; for (int i = 0 ; i < 2*n; ++i ) {//Same astronaut will be added twice int j = i%n ; String name = names[j] ; float height = h[j] ; double mass = w[j]; int year = yr[j] ; Astronaut a = new Astronaut ( name, height, mass,year ) ; crew.add ( a ) ; } return crew; } public static void main(String[] args) { MarsCrew crew = genCrew() ; crew.listSorted (); crew.listByExperience (); for (Astronaut a: crew) { crew.add ( a ) ; } Astronaut x = new Astronaut ( "ABC", 60, 60,2000 ) ; crew.add ( x ) ; crew.listByExperience (); }} class2: import java.util.TreeSet;// xxx Change Astronaut so that it can be added to a TreeSet.public class Astronaut extends TreeSet{ // xxx add something here … private String name; private float height; private double mass; private int year; public Astronaut(String name, float height, double mass, int year) { this.name = name; this.height = height; this.mass = mass; this.year = year ; } public String getName() { return name; } public float getHeight() { return height; } public double getMass() { return mass; } public double getYear() { return year; } public boolean isExperienced() { // xxx to be finished if (this.year <= 1999) { return true; } return false; } @Override public String toString() { String s = String.format ("%15s, height:%3.0f, mass:%3.0f, year:%d", name, height,mass, year ) ; return s ; } public int compareTo( Astronaut that ) { // xxx to be finished int x = this.getName().compareTo(that.getName()) ; if( x == 0 ) { float diff = this.getHeight() - that.getHeight(); if ( diff > 0 ) { x = 1; } else if ( diff < 0 ) { x = -1; } } if( x == 0 ) { double diff = this.getMass() - that.getMass(); if ( diff > 0 ) { x = 1; } else if ( diff < 0 ) { x = -1; } } return x; } // xxx use the best practice @Override public boolean equals(Object o) { // xxx to be finished Astronaut that = (Astronaut)o; return this.compareTo(that) == 0; } @Override public int hashCode() { // xxx to be finished return (int)(height + mass + year + name.hashCode()); } class3:  import java.util.*; public class AstronautMap extends TreeMap// what should this class extend?{ private static String[] NAMES = { "Cardman,Zena", "Rubins,Kathleen", "Hopkins,Michael", "Glenn,John", "Shepard,Alan" }; private static int[] START_YEARS = { 2017, 2009, 2009, 1959, 1959 }; public AstronautMap() { this.put(NAMES[0], START_YEARS[0]); this.put(NAMES[1], START_YEARS[1]); this.put(NAMES[2], START_YEARS[2]); this.put(NAMES[3], START_YEARS[3]); this.put(NAMES[4], START_YEARS[4]); } public String[] toStrings() { String[] astronauts = new String[5]; int index = 0; for(String name: NAMES) { astronauts[index] = name + " joined in" + this.get(name); index++; } return astronauts; } public void remove20thCentury() { HashSet toRemove = new HashSet(); for(String name: NAMES) { if ((int)this.get(name) <= 2000) { toRemove.add(name); } } // this.keySet().removeAll(toRemove); } public static void main(String[] args) { AstronautMap m = new AstronautMap (); for (String s: m.toStrings() ) { System.out.println ( s ); } }} Computer Science Engineering & Technology Java Programming COM SCI MISC Share QuestionEmailCopy link Comments (0)