This is my assignment about setter and getter and it is not working for some reason. Could anyone check what the problem is for me? Thank you.
public class FlightTest
{
public static void main (String [] args)
{
String name;
String number;
String Orig;
String Desti;
Scanner scan = new Scanner (System.in);
Flight data = new Flight ();
System.out.print ("Airline Name: ");
String AirlineName = scan.nextLine ();
data.setAirlineName (name);
System.out.print ("Flight Number: ");
String FlightNumber = scan.nextLine ();
data.setFlightNumber (number);
System.out.print ("Origin: ");
String Origin = scan.nextLine();
data.setOrigin (Orig);
System.out.print ("Destination: ");
String Destination = scan.nextLine ();
data.setDestination (Desti);
System.out.println (data);
}
}
public class Flight
{
private String AirlineName;
private String FlightNumber;
private String Origin;
private String Destination;
public String setAirlineName()
{
String Name = AirlineName;
return Name;
}
public Flight ()
{
AirlineName = "";
FlightNumber = "";
Origin = "";
Destination = "";
}
public String getAirlineName()
{
return AirlineName;
}
public void setAirlineName (String name)
{
AirlineName = name;
}
public String getFlightNumber ()
{
return FlightNumber;
}
public void setFlightNumber (String number)
{
FlightNumber = number;
}
public String getOrigin ()
{
return Origin;
}
public void setOrigin (String Orig)
{
Origin = Orig;
}
public String getDestination ()
{
return Destination;
}
public void setDestination (String Desti)
{
Destination = Desti;
}
public String toString ()
{
String result = AirlineName + " flight number " + FlightNumber + " leaves from " + Origin + " to " + Destination + ".";
return result;
}
}