public class Plane {
private String FlightNumber;
private String Location;
private boolean isLanding;
private int ScheduledTime;
private static int TotalPlanes;

public Plane(String FlightNumber, String Location){
this.FlightNumber = FlightNumber;
this.Location = Location;
Plane.TotalPlanes++;
}
public String getFlightNumber(){
return this.FlightNumber;
}
public void setFlightNumber(String f){
this.FlightNumber = f;
}
public String getLocation(){
return this.Location;
}
public void setLocation(String l){
this.Location = l;
}
public static int getTotalPlanes(){
return Plane.TotalPlanes;
}

public boolean

i wrote this far and i like to use boolean but i need to write with isLanding wheather it lands or take offs.

something like

public boolean isLanding(Plane c) {
return this.Plane.equals(c.Plane);

how should i write..?

public boolean getIsLanding()
{
return isLanding;
}

I think thats what you want


What I would do is change your non-static boolean field isLanding to:
private boolean landing;
Then use the method:
public boolean isLanding()
{
return landing;
}

It conforms more to how java code is written using get/is.

If you didn't realise, but you probably do, your constructor is only setting flightNumber and location, so that means:
isLanding(landing if you make the change I suggested)=false
scheduledTime=0
Since they are the default values for booleans and ints.
So upto you if you want to set them when you create a new Plane object

Also, in your methods:

public String getFlightNumber(){
return this.FlightNumber;
}
public void setFlightNumber(String f){
this.FlightNumber = f;
}
public String getLocation(){
return this.Location;
}
public void setLocation(String l){
this.Location = l;
}
public static int getTotalPlanes(){
return Plane.TotalPlanes;
}

You keep using this.someField, well with the way you've written it, you don't need to call this.
You can just refer to the field by its name.
However, with your set methods, its more customary for the argument name to have the same name as the field, in which case it is MANDATORY that you use this, so that it knows which variable you are refering to, eg:

public void setFlightNumber(String FlightNumber){
this.FlightNumber = FlightNumber;
}

And same for other set methods.
One more thing... best to keep your variables lowerCamelCase, that means first letter is lower case, and so on, and Classes as UpperCamelCase, hope that helps.

Comments
Nice helpful posts.
This article has been dead for over six months. Start a new discussion instead.