Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CAN SOMEONE PLEASE HELP ME W THIS JAVA PROJECT? This is the Spaceship class: public class Spaceship { private String name; private Location currentLocation; private
CAN SOMEONE PLEASE HELP ME W THIS JAVA PROJECT?
This is the Spaceship class:
public class Spaceship { private String name; private Location currentLocation; private Location destination; private int capacity; private int numberOfCrew = 0; private static int tripLength; //tripLength initialized private Traveler[] crew; final private static int DEFAULT_CAPACITY = 10; Spaceship () { this(null, null, null, DEFAULT_CAPACITY, tripLength); System.out.println("This is going to be bad news, no values are set"); } Spaceship (String name, Location currentLocation, Location destination, int capacity, int tripLength) { this.name = name; this.currentLocation = currentLocation; this.destination = destination; this.capacity = capacity; this.crew = new Traveler[capacity]; this.tripLength = tripLength; } public boolean board (Traveler t) { if (this.canBoard(t)) { this.crew[numberOfCrew++] = t; return true; } return false; } public boolean goAshore (Traveler t) { if (this.isOnBoard(t)) { this.remove(t); return true; } return false; } private void remove (Traveler t) { for (int i = 0; iThis is the code for the Traveler class:
public abstract class Traveler { // made abstract class private String name; private static int paxCreated = 0; private int id; private Location location; Traveler () { this("Bubba"); System.out.println("Name is required. Calling this traveler Bubba"); } Traveler (String name) { this(name, Location.EARTH); System.out.println("Location is required. Calling this location EARTH"); } Traveler (String name, Location location) { this.name = name; this.location = location; this.id = ++Traveler.paxCreated; } public abstract String toString (); // made abstract method and removed method body public abstract int addFlightToHistory(); // abstract addFlightToHistory method public Location getLocation () { return this.location; } public String getName () { return this.name; } public int getId () { return this.id; } public void setLocation (Location l) { this.location = l; } }Project Requirements: 1. The Classes from Project 2 (Traveler and Spaceship) will be reused with the modifications listed in the class description 1. Starter code for these classes is provided, but feel free to use your own if you prefer 2. SeatCategory class the class for identifying the three SeatCategories: 1. The options are NOSEAT, FIRST, BUSINESS, COACH. 2. Implement the SeatCategory class as a Java Enum 3. Traveler Class 1. Abstract class 2. Instance variables and static nextIdNum same as project 2. 3. Methods 1. Constructors and methods same as project 2 except: 2. Abstract toString method as each class will provide a different version 3. Abstract addFlightToHistory which takes an int representing the flight duration 4. Passenger Class 1. Subclass of Traveler class 2. A class that stores specific Passenger information such as flight cost, seat class and rewards program status 3. Instance Variables 1. cost - double representing the cost of the flight based on the following 1. First class $1499.99 2. Business class $998.00 3. Coach $449.00 2. seat current SeatClass of the passenger. 3. rewardsPoints int representing the number of rewards points of the passenger. 4. Methods 1. Default constructor sets all instance variables to a default value 1. Call the super class constructor passing appropriate parameters to it 2. Set the rest of the variables to a default value 3. Attempts to upgrade passenger if possible, using rewardUpgrade function defined below 2. Parameterized Constructor 1. Takes in all parameters required to set the instance variables including super class's instance variables. 2. Cost should be set based on seat class Project Requirements: 1. The Classes from Project 2 (Traveler and Spaceship) will be reused with the modifications listed in the class description 1. Starter code for these classes is provided, but feel free to use your own if you prefer 2. SeatCategory class the class for identifying the three SeatCategories: 1. The options are NOSEAT, FIRST, BUSINESS, COACH. 2. Implement the SeatCategory class as a Java Enum 3. Traveler Class 1. Abstract class 2. Instance variables and static nextIdNum same as project 2. 3. Methods 1. Constructors and methods same as project 2 except: 2. Abstract toString method as each class will provide a different version 3. Abstract addFlightToHistory which takes an int representing the flight duration 4. Passenger Class 1. Subclass of Traveler class 2. A class that stores specific Passenger information such as flight cost, seat class and rewards program status 3. Instance Variables 1. cost - double representing the cost of the flight based on the following 1. First class $1499.99 2. Business class $998.00 3. Coach $449.00 2. seat current SeatClass of the passenger. 3. rewardsPoints int representing the number of rewards points of the passenger. 4. Methods 1. Default constructor sets all instance variables to a default value 1. Call the super class constructor passing appropriate parameters to it 2. Set the rest of the variables to a default value 3. Attempts to upgrade passenger if possible, using rewardUpgrade function defined below 2. Parameterized Constructor 1. Takes in all parameters required to set the instance variables including super class's instance variables. 2. Cost should be set based on seat class
Step 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