Question
In Java I have made the required method, but I'm not sure as to what needs to go in it. the requirement is as follows:
In Java I have made the required method, but I'm not sure as to what needs to go in it.
the requirement is as follows:
Abstract addFlightToHistory which takes an int representing the flight duration.
My code:
abstract class Traveler { public static int nextIDNum = 0; 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"); this.name = null; this.location = null; nextIDNum = 1; this.id = nextIDNum; nextIDNum ++; } 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; nextIDNum = 1; id = nextIDNum; nextIDNum++; }
public void setLocation (Location l) { this.location = l; }
public Location getLocation () { return this.location; }
public String getName () { return this.name; } public void setId() { id = nextIDNum; nextIDNum++; }
public int getId () { return this.id; } public String toString () { return "[name = "+ this.name +", id = " + this.id + ", current = " + this.location + "]"; }
public void addFlightToHistory() { // TODO Auto-generated method stub } }
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