Question: Java: Please help with this Tester Part 1: Please see the code I have so far for that part. Thank you. INSTRUCTIONS: T RAVELER CLASS:
Java: Please help with this Tester Part 1: Please see the code I have so far for that part. Thank you.
INSTRUCTIONS:


TRAVELER CLASS:
enum Location
{
EARTH, MARS, BELT, RING;
}
public class Traveler
{
//static variable int nextIDNum
private static int nextIDNum;
private String name;
private int id;
private Location current;
public Location getCurrent()
{
return current;
}
public void setCurrent(Location aCurrent)
{
current = aCurrent;
}
//constructor to set name and location
public Traveler(String aName, Location aCurrent)
{
super();
name = aName;
setId();
}
public Traveler()
{
super();
}
public String getName()
{
return name;
}
public void setName(String aName)
{
name = aName;
}
public int getId()
{
return id;
}
public void setId()
{
id = ++nextIDNum;
}
//toString to return object data
@Override
public String toString()
{
return "Traveler[name = " + name + ",id" + id +",location=" + current.name() + "]";
}
}
SPACESHIP CLASS:
enum Location {
EARTH, MARS, BELT, RING;
}
class Traveller {
private static int nextIDNum;
private String name;
private int id;
private Location current;
public Location getCurrent() {
return current;
}
public void setCurrent(Location aCurrent) {
current = aCurrent;
}
// constructor to set name and location
public Traveller(String aName, Location aCurrent) {
super();
name = aName;
current = aCurrent;
setId();
}
public Traveller() {
super();
}
public String getName() {
return name;
}
public void setName(String aName) {
name = aName;
}
public int getId() {
return id;
}
public void setId() {
id = ++nextIDNum;
}
// toString to return object data
@Override
public String toString() {
return "Traveller [name=" + name + ", id=" + id + ", location=" + current.name() + "]";
}
SPACESHIP TESTER
public class SpaceShipTester {
private static final Object Object = null;
public static void main(String[] args)
{
Traveler t1 = new Traveler();
t1.setId();
t1.setName("Naomi");
t1.setCurrent(Location.EARTH);
System.out.println(t1);
Traveler t2 = new Traveler("Klaes", Location.MARS);
System.out.println(t2);
}
public static void main1(String[] args)
{
Traveler t1 = new Traveler();
//Object getID;
t1.setId();
t1.setName("Naomi");
t1.setCurrent(Location.EARTH);
Traveler t2 = new Traveler("Klaes", Location.MARS);
//Traveler t2 = new Traveler("Klaes", Location.MARS);
Traveler t3 = new Traveler("Lucinda", Location.MOON);
Traveler t4 = new Traveler("Amos", Location.MARS);
for(int i = 1; i
System.out.println("Date for Traveler " + t1.getID());
if(t1.equals(Object))
System.out.println("Name: " + t1.getName());
if(t1.equals(Object))
System.out.println("Current: " + t1.getCurrent());
if(t1.equals(Object))
System.out.println("Traveler " + t1.getID());
System.out.println(t1);
}
}
}
SpaceShipTester class with a main method: A text-based driver program that performs the following steps: a. It asks for four Travelers and two StarShips (Part 1, below) b. It executes a text-menu with the following options (Parts 2-4 below) 1. Add traveler to a Spaceship 1. Search for traveler on a Spaceship 11. Move a spaceship to a new location . Exit the program SpaceShipTester class with a main method: A text-based driver program that performs the following steps: a. It asks for four Travelers and two StarShips (Part 1, below) b. It executes a text-menu with the following options (Parts 2-4 below) 1. Add traveler to a Spaceship 1. Search for traveler on a Spaceship 11. Move a spaceship to a new location . Exit the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
