Okay so I'm creating a simple flight booking system. I've spent a fair bit of time debugging and now even the simplest things are stumping me.
I have an interface which looks close to:
public class Flight implements IFlight {
String destination;
String departure;
int clubrows = 0;
int ecorows = 0;
public Flight(String dest, String dept, int clubrow, int ecorow) {
destination = dest;
departure = dept;
clubrows = clubrow;
ecorows = ecorow;
}
public String getDestination() {
return destination;
}
This class has many similar get methods. Now i'm trying to write a for loop where every value that is put in is printed out. So i need to access all the 0 values then all the 1 values etc. it looks kinda like this right now:
public void flightManifest() {
System.out.println("Available flights: ");
for(int i=0; i<flightCount ;i++){
System.out.println("Flight number: "+flightCount +", Destination: "+ +", Departure time: "+ );
}
So essentially whenever i try to access the variables i keep balls-ing it up, so how am i meant to access these values each time round?
So the way I store them is as such: flightArr[flightCount] = new Flight (dest, dept, clubrow, ecorow); flightCount++; or at least thats how it is made.
Flightclass should have private fields. UsegetXX()methods to access the values. There is also no need to setintvalues to0unless you have a constructor that doesn't assign them values.