Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is what I have so far for a flight program. I was told Im missing 2 things. 1) Must have two constructors, one accepts

image text in transcribed

This is what I have so far for a flight program.

I was told Im missing 2 things.

1) Must have two constructors, one accepts nothing and another overloaded constructor that accepts parameters. (I have a constructor named "public class Flight" that accepts parameters, I dont have one that "accepts nothing"

2)I also need to make sure I test ALL methods. He said it seemed like I only tested setDestination, not the other mutators.

Code so far:

public class Flight { private String name; private int number; private String origin; private String destination; public Flight(String name, int number, String origin, String destination) { this.name = name; this.number = number; this.origin = origin; this.destination = destination; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public String getOrigin() { return origin; } public void setOrigin(String origin) { this.origin = origin; } public String getDestination() { return destination; } public void setDestination(String destination) { this.destination = destination; } public String toString() { return "NAME: "+ name +" FLIGHT NUMBER: "+ number +" ORIGIN: "+ origin +" DESTINATION: "+ destination +" "; } }

public class FlightTest {

public static void main(String[] args) { Flight f1 = new Flight("Alpha", 2296, "Burbank, CA", "Dallas, TX"); Flight f2 = new Flight("Bravo", 1542, "Chicago, IL", "Louisville, KY"); Flight f3 = new Flight("Charlie", 9526, "Denver, CO", "San Antonio, TX");

System.out.println("CURRENTLY RUNNING FLIGHTS"); System.out.println(f1); System.out.println(f2); System.out.println(f3); f2.setDestination("Atlanta, GA"); System.out.println("**Flight " + f2.getName()+" has been re-routed to " + f2.getDestination() + " due to severe weather.** "); System.out.println("\t********\t UPDATED FLIGHT INFORMATION \t********\t"); System.out.println("CURRENTLY RUNNING FLIGHTS"); System.out.println(f1); System.out.println(f2); System.out.println(f3);

}

}

CURRENTLY RUNNING FLIGHTS NAME: Alpha FLIGHT NUMBER: 2296 ORIGIN: Burbank, CA DESTINATION: Dallas, TX NAME: Bravo FLIGHT NUMBER: 1542 ORIGIN: Chicago, IL DESTINATION: Louisville, KY NAME: Charlie FLIGHT NUMBER: 5915 ORIGIN: Denver, CO DESTINATION: San Antonio, TX **Flight Bravo has been re-routed to Atlanta, GA due to severe weather. ** ****** ******** UPDATED FLIGHT INFORMATION CURRENTLY RUNNING FLIGHTS NAME: Alpha FLIGHT NUMBER: 2296 ORIGIN: Burbank, CA DESTINATION: Dallas, TX NAME: Bravo FLIGHT NUMBER: 1542 ORIGIN: Chicago, IL DESTINATION: Atlanta, GA NAME: Charlie FLIGHT NUMBER: 5915 ORIGIN: Denver, CO DESTINATION: San Antonio, TX

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

Contrast total slack and free slack.

Answered: 1 week ago

Question

=+c. Shanna spends $30 to get a haircut.

Answered: 1 week ago