hi there, i am currently doing a dvd rental system. I have a client class and a salesperson class(both inherit from a Person class), Dvd class, Loan class, DvdShop class and the Runner class. Now, my problem is that I have to do a method where the user can delete a client from the client list (which is an arraylist named cList) BUT cannot delete the client if he has a a dvd still not returned back. I have already done the delete method but i don't know how to do the part where the program checks if the client id is in a loan. The loans are kept in a LoanList (which is also an array list)
Can you help please??
Here is what I did so far;
THIS IS IN THE DvdShop;
public int removeClient (int IDToSearch)
{
for(int i=0; i<cList.size(); i++)
{
Client tmpClient = (Client)cList.get(i);
if(tmpClient.GetId() == IDToSearch)
{
cList.remove(i);
return i;
}
}
return -1;
}
WHILE THIS IS IN THE RUNNER CLASS;
case 8:
//Delete a Client from the DvdShop
System.out.println("Enter ID of Client you want to delete: ");
int indexPo = myDvdShop.removeClient(sc.nextInt());
if(indexPo!= -1)
{
//Person exists and his position in array list is retrieved
System.out.println("Client deleted");
}
else
{
//Person does not exists
System.out.println("No matching ID found to delete!! ");
}
break;
thanks verymuch