I'm writing a class to represent a flight. The only error I'm getting is on line 97.
Flight.java:97: error: missing return statement
/**
Class Flight represents a plane at an airline
Author: Anna Mae Decker
E-mail address: adecker0033@kctcs.edu
Last changed: 02/10/13
Assignment1
*/
public class Flight {
/*
* declare instance variables
* each flight object that is created will have its own copy of these
* These are declared as private to ensure that external Java code
* cannot access them directly and assign any arbitrary values to them.
*/
String flightNumber;
int rows;
int seatsPerRow;
boolean [][] seat;
double fare;
String origin;
String destination;
/*
* The constructor
* Contains code that initially sets up each flight object when it is
* first created. Always has the same name as the class.
*/
public Flight (String flightNumber, int rows, int seatsPerRow, double fare, String origin, String destination) {
//call the mutator methods and let them initialize the instance variables
setFlightNumber(flightNumber);
setRows(rows);
setSeatsPerRow(seatsPerRow);
setFare(fare);
setOrigin(origin);
setDestination(destination);
seat = new boolean [rows][seatsPerRow];
for(int i = rows; i>0; i--){
for(int x = seatsPerRow; x>0; x--){
seat[i][x] = true;
}
}
}
/*
* The accessor methods
* These report the current values of the Flight object's instance variables
*/
public String getFlightNumber() {
return flightNumber;
}
public int getRows() {
return rows;
}
public int getSeatsPerRow() {
return seatsPerRow;
}
public double getFare() {
return fare;
}
public String getOrigin() {
return origin;
}
public String getDestination() {
return destination;
}
public boolean isAvailable(int userRow, int userSeatPerRow) {
return !seat[userRow][userSeatPerRow];
}/
//THIS METHOD IS THE ONE THAT IS CAUSING THE ERROR? AM I PLACING THE RETURN STATEMENT IN THE WRONG LOCATION?
public boolean anyAvailable(int userRow, int userSeatPerRow){
for(int row = 0; row < getRows(); row++){
for(int column = 0; column < getSeatsPerRow(); column++){
if(!seat[userRow][userSeatPerRow]) {
return true; //<<<<<HERE IS LINE 97
}
}
}
}
/*
* The mutator methods
* These allow the Flight object's instance variables to be assigned new values
*/
public void setFlightNumber(String flightNumber) {
//trim the title parameter to remove any white space at the ends of the
//String. Then test if the remaining String contains at least one
//character. If so, title is valid.
if ((flightNumber.trim()).length() > 0) {
this.flightNumber = flightNumber;
}
}
public void setRows(int rows) {
if (rows >= 0) {
this.rows = rows;
}
}
public void setSeatsPerRow(int seatsPerRow) {
if (seatsPerRow >= 0) {
this.seatsPerRow = seatsPerRow;
}
}
public void setSeat(int rows, int seatsPerRow, boolean seat[][]) {
if (rows >= 0) {
if (seatsPerRow >=0) {
seat = new boolean [rows][seatsPerRow];
}
}
}
public void setFare(double fare) {
if (fare >= 0) {
this.fare = fare;
}
}
public void setOrigin(String origin) {
if ((origin.trim()).length() > 0) {
this.origin = origin;
}
}
public void setDestination(String destination) {
if ((destination.trim()).length() > 0) {
this.destination = destination;
}
}
}//end of class