/** * Constructor for objects of class Member */ public Member(String firstname,String lastname,String phone, int id) { //constructor if(id > 0) { if(id == this.memberID) { System.out.println("Error: Member ID '" + id + "' already exists"); } else { this.firstname = firstname; this.lastname = lastname; this.phone = phone; this.memberID = id; } } else { System.out.println("Member ID MUST be a positive integer"); } }
Hi guys. This is suppose to be a lending Library. with every member issued a unique Id. but before issuing this ID I need to do a test that the issued ID is not already in use. I wrote this if statement but it doesnt work because I ve just issued this same ID to 3 different members and it was not detected.. Help! I would like to create a system where they are issued with a RAMDOM number after a test has been carried out and they not already in use. cheers for all inputs