// Verbose version

public Voter(String VoterInfo)

    {

        int count = 0;

        String [] info = new String[3];

        Scanner voterScan = new Scanner(VoterInfo);

        voterScan.useDelimiter(",");

        while (voterScan.hasNext())

        {

            info[count] = voterScan.next();

            count++;

        }

        VoterID = new ID(info[0]);

        VoterName = info[1];

        VoterPassword = info[2];      

    }

   

 

 

 

    // verbose version

public int compareTo(Object obj)

    {

        Voter otherVoter = (Voter)obj;

        ID voter1 = this.getVoterID();

        ID voter2 = otherVoter.getVoterID();

       

        if(voter1.compareTo(voter2)==1)

        {

            return 1;

        }

        else if(voter1.compareTo(voter2)==0)

        {

            return 0;

        }

        else

        {

            return -1;

        }

    }

 

 

 
 // straight forward version

public Voter(String VoterInfo)

    {

        Scanner voterScan = new Scanner(VoterInfo);

        voterScan.useDelimiter(",");

 

        VoterID = new ID(voterScan.next());

        VoterName = voterScan.next();

        VoterPassword = voterScan.next();

    }

 

 

 

 

 

 

 

 

 

 

// straight forward version

public int compareTo(Object obj)

    {

        Voter otherVoter = (Voter)obj;

        ID voter1 = this.getVoterID();

        ID voter2 = otherVoter.getVoterID();

        res = voter1.compareTo(voter2);

        return res;

    }

 


// complex version

public boolean matches (String votersID, String password)

    {

        if(votersID.endsWith((this.VoterID.toShortString())))

        {

            if(password.equals(VoterPassword))

            {

                return true;

            }

            else

            {

                return false;

            }                       

        }

        else

        {

            return false;

        }

    }

 


 

// simple replacement line

if(votersID.equals(this.VoterID.getId()))

 

 

 


 // unneeded until you’re more advanced

public int hashCode()

    {

        int hash = 5;

        hash = 97 * hash + (VoterName != null ? this.VoterName.hashCode() : 0);

        return hash;

    }

 

 

 

// unneeded until you’re more advanced

    @Override

    public int hashCode() {

        int hash = 7;

        hash = 89 * hash + (this.VoterID != null ? this.VoterID.hashCode() : 0);

        hash = 89 * hash + (this.VoterName != null ? this.VoterName.hashCode() : 0);

        hash = 89 * hash + (this.VoterPass != null ? this.VoterPass.hashCode() : 0);

        hash = 89 * hash + (this.HasVoted != null ? this.HasVoted.hashCode() : 0);

        return hash;

    }