In this method I am trying to locate a user by its ID and then remove it. I am having errors in the second if statment (cannot find symbol-method getID() ).
static void removeMember(ArrayList<GymUser> UserListIn)
{
Scanner keyboard = new Scanner(System.in);
keyboard.useDelimiter("\n");
System.out.print("Enter the ID no of the member to be removed: ");
String ID = keyboard.next();
int location = -1;
if (UserListIn.size() == 0){
System.out.println("You have no members to remove!");
}
else {
for (int i=0; i<=UserListIn.size(); i++)
{
if (UserListIn.getID() == ID) //having error
{
location = i;
break;
}
//location = UserListIn.indexOf(new GymUser(ID,null, null,null,null,null,null,null));
}
if (location == -1)
{
System.out.println("The ID No. you have entered does not exist in this database!");
}
else UserListIn.remove(location);
}
}
//class that contains methods..
import java.io.*;
public class GymUser implements Serializable
{
//these are instance variables
private String m_UserrID;
private String m_UserName;
private String m_UserID;
private String m_UserSurname;
private String m_UserAddress;
private int m_UserPhone;
private int m_UserAge;
private String m_UserDuration;
//this is the constructor
public GymUser(String UserrID,String UserName,String UserID,String UserSurname, String UserAddress, int UserPhone, int UserAge,String UserDuration)
{
m_UserrID = UserrID;
m_UserName = UserName;
m_UserSurname = UserSurname;
m_UserAddress = UserAddress;
m_UserPhone = UserPhone;
m_UserAge= UserAge;
m_UserID = UserID;
m_UserDuration = UserDuration;
}
public String getM_ID()
{
return m_UserrID;
}
// method to get the membership duration
public String getDuration()
{
return m_UserDuration;
}
// method to get the name
public String getName()
{
return m_UserName;
}
//method to set name
public void setName(String UserName)
{
m_UserName = UserName;
}
//method to return age
public int getAge()
{
return m_UserAge;
}
//method to set age
public void setAge(int UserAge)
{
m_UserAge =UserAge;
}
//method to return address
public String getAddress()
{
return m_UserAddress;
}
//method to set address
public void setAddress(String UserAddress)
{
m_UserAddress= UserAddress;
}
//method to return phone
public int getPhone()
{
return m_UserPhone;
}
//method to set phone
public void setPhone(int UserPhone)
{
m_UserPhone = UserPhone;
}
//method to return suname
public String getSurname()
{
return m_UserSurname;
}
//method to set surname
public void setSurname(String UserSurname)
{
m_UserSurname = UserSurname;
}
//method to get name
public String getID()
{
return m_UserID;
}