Just need someone to confirm that what ive done is good . It compiles but i need confirmation that its good and up to standards .
this is the first class
import java.io.Serializable;
public class Flight implements Serializable
{
//instance variables
private String flightNumber;
private String day;
private String destination;
private int freeSeats;
private String error;
// constructors
public Flight()
{
this.flightNumber = " ";
this.day = " ";
this.destination = " ";
this.freeSeats = 0;
}
public Flight(String fNum, String day, String destination, int seatsBooked, int seatSold, int freeSeats)
{
this.flightNumber = fNum;
this.day = day;
this.destination = destination;
this.freeSeats = freeSeats;
}
public String getFlightNumber()
{
return this.flightNumber;
}
public String getDay()
{
return this.day;
}
public String getDestination()
{
return this.destination;
}
public int getFreeSeats()
{
return this.freeSeats;
}
public String flightNumber()
{
if(flightNumber.matches("EL[0-9][0-9][0-9]"))
{
this.flightNumber = flightNumber;
System.out.println("Flight Number Accepted");
return this.flightNumber;
}//end if
else
{
System.out.println("Invalid Number......Flight Number Must Start With EL And Have 3 Digits");
return error;
}//end else
}
public String day()
{
if(day.matches("[Monday][Tuesday][Wednesday][Thursday][Friday][Saturday][Sunday]"))
{
this.day = day;
System.out.println("You Will Be Traveling On " + this.day);
return this.day;
}// end if statement
else
{
System.out.println("Invalid option choosen");
return error;
}
}
public String destination()
{
this.destination = destination;
return this.destination;
}
public int freeSeats(int freeSeats)
{
if(freeSeats < 10 && freeSeats > 0)
{
System.out.println("Seats Available");
return this.freeSeats;
}
else
{
System.out.println("No Seats availabele");
return 0;
}
}
public void display()
{
System.out.println(" Please Enter Flight Number Please: " + this.flightNumber);
System.out.println(" Enter Day Of Departure: " + this.day);
System.out.println(" Enter Destination: " + this.destination);
System.out.println("Number Of avaialable Seats + " + this.freeSeats);
}
}
********************************************************************
*******************************************************************
This is the second class
import java.io.Serializable;
public class Passenger implements Serializable
{
//instance variables
private String name;
private String address;
private String emailAddress;
private Flight flightBooked;// will hol the adress of the flight object
private String flightValid;
private String answer;
//constructors
public Passenger()
{
this.name = " ";
this.address = " ";
this.emailAddress = " ";
this.flightBooked = null;
}
public Passenger(String name, String address, String emailAddress, Flight flightBooked)
{
this.name = name;
this.address = address;
this.emailAddress = emailAddress;
this.flightBooked = flightBooked;
}
//Getter methods
public String getName()
{
return this.name;
}
public String getAddress()
{
return this.address;
}
public String getEmailAddress()
{
return this.emailAddress;
}
public Flight getFlightBooked()
{
return this.flightBooked;
}
//Setter methods
//Getter methods
public String name()
{
this.name = name;
System.out.println("Please Enter Name");
return this.name;
}
public String address()
{
this.address = address;
System.out.println("Please Enter Address");
return this.address;
}
public String email()
{
this.emailAddress = emailAddress;
System.out.println("Please Enter Email");
return this.emailAddress;
}
public Flight flightBooked()
{
this.flightBooked = flightBooked;
System.out.println("Enter Flight Number");
return this.flightBooked;
}
//create a flight here to store info about the flight!
public boolean flightValid()
{
if(flightValid.equals("Yes"))
{
return true;
}
else
{
return false;
}
}
public void displayP()
{
System.out.println(" Please Enter Name: " + this.name);
System.out.println(" Please Enter ADrress: " + this.address);
System.out.println(" Enter Email: " + this.emailAddress);
System.out.println(" flight Booked?: " + this.flightBooked);
}
}