Can anyone help! have 12 hours before must turn in this project and still getting errors, but got htem down to one. Here it is:

F:\CPT244\Programs\Tests\Chapter 13 & 14 Test\Lab 1\FlightListMain.java:54: cannot find symbol
symbol : constructor Flight(java.lang.String,java.lang.String)
location: class Flight
Flight target = new Flight("Detroit, MI", "Miami, FL");
^
1 error

Tool completed with exit code 1

//********************************************************************
//  FlightListMain.java---Linda Schwalbauch---Chapter 13 & 14 Test
//
//       Demonstrates a linear search of Comparable objects.
//********************************************************************
import java.util.*;
import java.lang.*;
import java.util.Calendar;

public class FlightListMain
{
   //-----------------------------------------------------------------
   //  Creates an array of Flight objects, then searches for a
   //  particular flight.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      Flight[] planes = new Flight[7];

      planes[0] = new Flight("Reno, NV", "Los Angeles, CA", "Us Airways",
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 9, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 11, 40));

	  planes[1] = new Flight("Charleston, SC", "New York, NY", "Con Air",
	  			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 8, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 12, 30));

	  planes[2] = new Flight("Indianapolis, IN", "Columbia, SC", "Pan Am",
	  			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 9, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 12, 40));

	  planes[3] = new Flight("Indianapolis, IN", "Columbus, OH", "Delta",
	  			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 9, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 12, 40));

	  planes[4] = new Flight("Reno, NV", "Los Angeles, CA", "Us Airways",
	  			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 2, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 4, 50));

	  planes[5] = new Flight("Detroit, MI", "Miami, FL", "Pan Am",
	  			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 9, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 10, 00));

	  planes[6] = new Flight("Philidelphia, PA", "Pittsburg, PA", "Con Air",
	  			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 8, 30),
      			  new GregorianCalendar(2010, Calendar.DECEMBER, 27, 9, 50));


      SortingFlight.selectionSort(planes);

	  for (Comparable plane : planes)
         System.out.println (plane);

      Flight target = new Flight("Detroit, MI", "Miami, FL");

      Flight found = (Flight)SearchingFlights.linearSearch(planes, target);
      if (found == null)
         System.out.println ("Flight was not found.");
      else
         System.out.println ("Found: ");
    	 System.out.println(found);
	 }
}

//********************************************************************
//  Flight.java       Java Foundations
//
//  Represents a Commercial Flight List that implements Comparable.
//********************************************************************
import java.util.*;
import java.lang.*;

public class Flight implements Comparable
{
   private String sourceCity, destinationCity, airline;
   private Calendar departTime, arrivalTime;
   //------------------------------------------------------------------
   //  Sets up this flight with the specified information.
   //------------------------------------------------------------------
   public Flight(String sourceCity, String destinationCity, String airline,
                 Calendar departTime, Calendar arrivalTime)
   {
	   this.sourceCity = sourceCity;
       this.destinationCity = destinationCity;
       this.airline = airline;
       this.departTime = departTime;
       this.arrivalTime = arrivalTime;
   }

   public GregorianCalendar (int hour, int minutes)
   {
	   this.hour = hour;
	   this

   //-----------------------------------------------------------------
   //       Gets the source city, where flight will be leaving
   //-----------------------------------------------------------------
   public String getSourceCity()
   {
	   return sourceCity;
   }

   //-----------------------------------------------------------------
   //                 Sets the source city.
   //-----------------------------------------------------------------
   public void setSourceCity(String sourceCity)
   {
	   this.sourceCity = sourceCity;
   }

   //-----------------------------------------------------------------
   // Gets the Destination City, where this flights final landing
   // will be.
   //-----------------------------------------------------------------
   public String getDestinationCity()
   {
	   return destinationCity;
   }

   //-----------------------------------------------------------------
   // Sets The destination city, where this flights final landing
   // will be.
   //-----------------------------------------------------------------
   public void setDestinationCity(String destinationCity)
   {
	   this.destinationCity = destinationCity;
   }

   //-----------------------------------------------------------------
   //              Gets the name of the AirLine.
   //-----------------------------------------------------------------
   public String getAirline()
   {
	   return airline;
   }

   //-----------------------------------------------------------------
   //            Sets up the name of the airline.
   //-----------------------------------------------------------------
   public void setAirline(String airline)
   {
	   this.airline = airline;
   }

   //------------------------------------------------------------------
   // Gets the time the flight will leave the source city, the
   // departure time.
   //------------------------------------------------------------------
   public Calendar getDepartTime()
   {
	   return departTime;
   }

   //------------------------------------------------------------------
   //  Sets the Departure time, when flight will leave source city
   //------------------------------------------------------------------
   public void setDepartTime(Calendar departTime)
   {
	   this.departTime = departTime;
   }

   //-----------------------------------------------------------------
   // Gets the Arrival time, when the flight will arrive at the
   // destination city
   //-----------------------------------------------------------------
   public Calendar getArrivalTime()
   {
	   return arrivalTime;
   }

   //------------------------------------------------------------------
   // Sets the arrival date, day flight will reach the destination city
   //------------------------------------------------------------------
   public void setArrivalTime(Calendar arrivalTime)
   {
	   this.arrivalTime = arrivalTime;
   }

   //------------------------------------------------------------------
   //  Uses the destination city and source city, or departure city
   // to determine the alphabetical order of the elements.
   //------------------------------------------------------------------

   public int compareTo (Object other)
   {
	  int result;

	  if (destinationCity.equals(((Flight)other).destinationCity))
	 	   result = sourceCity.compareTo(((Flight)other).sourceCity);
	  else
	  	   result = destinationCity.compareTo(((Flight)other).destinationCity);

      return result;

   }
   //--------------------------------------------------------------------
   // Gets the calendar information to print the time and date in a
   // nice readable form and sets index for the month index + 1,
   // because the month of January is indexed at 0 so need to add
   // 1 to it to set index to 1 instead of 0.
   //--------------------------------------------------------------------
   public String getArrivalCalendarString()
   {
       Calendar cal = getArrivalTime();

       return (cal.get(Calendar.MONTH) + 1) + "\\" +
       		   cal.get(Calendar.DAY_OF_MONTH) +
	           "\\" + cal.get(Calendar.YEAR) +
	           " " + cal.get(Calendar.HOUR_OF_DAY) +
	           ":" + cal.get(Calendar.MINUTE);
    }

    //--------------------------------------------------------------------
    //            Sets the departure date up as a String.
    //--------------------------------------------------------------------
    public String getDepartureCalendarString()
    {
	    Calendar cal = getDepartTime();

        return (cal.get(Calendar.MONTH) + 1) + "\\" +
                cal.get(Calendar.DAY_OF_MONTH) +
	    	    "\\" + cal.get(Calendar.YEAR) +
	    	    cal.get(Calendar.HOUR_OF_DAY) +
        		":" + cal.get(Calendar.MINUTE);
    }

    //----------------------------------------------------------------------
    //  Returns a string representation of this bag.
    //----------------------------------------------------------------------
    public String toString()
    {
	    return ("Airline: " + getAirline() + "\n" +
    			"Departure " + getSourceCity() + " @ " + getDepartureCalendarString() + "\n" +
    			"Arrival " + getDestinationCity() +	" @ " + getArrivalCalendarString() + "\n");
    }
}


//********************************************************************
//  Searching.java       Java Foundations
//
//  Contains various search algorithms that operate on an array of
//  Comparable objects.
//********************************************************************
import java.lang.*;
public class SearchingFlights
{
   //-----------------------------------------------------------------
   //  Searches the specified array of objects using a linear search
   //  algorithm. Returns null if the target is not found.
   //-----------------------------------------------------------------
   public static Comparable linearSearch (Comparable[] data, Comparable target)
   {
      Comparable result = null;
      int index = 0;

      while (result == null && index < data.length)
      {
         if (data[index].compareTo(target) == 0)
            result = data[index];
         index++;
      }

      return result;
   }
}

//********************************************************************
//  SortingFlight.java       Java Foundations
//
//  Contains various sort algorithms that operate on an array of
//  Comparable objects.
//********************************************************************
import java.lang.*;
public class SortingFlight
{
   //-----------------------------------------------------------------
   //  Sorts the specified array of integers using the selection
   //  sort algorithm.
   //-----------------------------------------------------------------
   public static void selectionSort (Comparable[] data)
   {
      int min;

      for (int index = 0; index < data.length-1; index++)
      {
         min = index;
         for (int scan = index+1; scan < data.length; scan++)
            if (data[scan].compareTo(data[min]) < 0)
               min = scan;

         swap (data, min, index);
      }
   }

   //-----------------------------------------------------------------
   //  Swaps two elements in the specified array.
   //-----------------------------------------------------------------
   private static void swap (Comparable[] data, int index1, int index2)
   {
       Comparable temp = data[index1];
       data[index1] = data[index2];
       data[index2] = temp;
   }

}

I am only getting the one error message, but if you see something else that will cause an error please help! All id welcome. I just need to make this program run before 7 pm tomorrow! Thanks a whole lot in advance!

Recommended Answers

All 3 Replies

The arguments to your constructor require more parameters than what you're providing. You have

Flight(String, String)

when you should have

Flight(String, String. String, String, String)

, according to your constructor.

Now I am getting still getting an error message. What you mean to do is search for the same amoutn of information stored, like the sourceCity, destinationCity, the airlines, and the time and date as string characters. I have added to the statement and still am getting the error on this line:

Flight target = new Flight("Detroit, MI", "Miami, FL", "Pan AM", " ", " ");

Are you getting the same error as before? If not could you post it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.