package abhijith.carboncontacts;

/*
    Object of this class depicts a single phone number.
    Each phone number within a contact is considered as a different object
*/


public class PhoneContact implements Comparable<PhoneContact> {

    private String contactNumber;
    private String contactName;
    private String contactType;
    private String contactID;
    private String contactNumberID;

    //TODO: Add more fields like display pic, email etc for better user experience

    PhoneContact(String number, String name, String type, String id, String phoneNumberID){
        contactNumber = number.trim().replaceAll(" ","");
        contactName = name;
        contactType = type;
        contactID = id;
        contactNumberID = phoneNumberID;
    }

    /*Getters for each phone contact field*/

    String getContactNumber(){
        return contactNumber;
    }
    String getContactName(){
        return contactName;
    }
    String getContactType(){
        return contactType;
    }
    String getContactID(){
        return contactID;
    }
    String getContactNumberID(){
        return contactNumberID;
    }

    //Comparator to sort the PhoneContact objects according to the number
    @Override
    public int compareTo(PhoneContact another) {
        return new String(this.getContactNumber()).compareTo(new String(another.getContactNumber()));
    }
}

@@ -576,31 +576,110 @@
 D)%7B%0A        
-contact
+String tempNumber;%0A        tempNumber = number.trim().replaceAll(%22 %22,%22%22);%0A        temp
 Number = num
@@ -667,33 +667,37 @@
    tempNumber = 
-n
+tempN
 umber.trim().rep
@@ -697,35 +697,152 @@
 m().replaceAll(%22
- %22,
+-%22,%22%22);%0A        tempNumber = tempNumber.trim().replace(%22(%22, %22%22);%0A        contactNumber = tempNumber.trim().replace(%22)%22, 
 %22%22);%0A        con

Fix bug that unable to detect duplicate contact with - or ()