can you help me to solve this Design a Person class similar
can you help me to solve this. Design a Person class similar to the Coin class defined in this chapter. Then design and implement a driver class called SelectPerson whose main method creates two Person objects, then randomly selects a gender in both to see in which object a female gender is selected two times in a row. Consider the possibility that they might tie. Print the results of each selection and then print the object name which comes up first with the female gender being selected twice, consecutively
Solution
public class SelectPerson{
     public static void main(String []args){
          //create two person objects
          Person p1=new Person();
          Person p2=new Person();
          //delcare variable to set intiial values
          int count1=0,count2=0,counter=0;
        
          //loop until two consequetive femailes aren\'t listed
          while(count1<2 && count2<2)
          {
              counter++;
              p1.setGender();
              p2.setGender();
              //display selection of eahc round
               System.out.println(\"*******Round \"+counter+\"*****\");
              System.out.println(\"Object1 = Gender :\"+p1);
               System.out.println(\"Object2 = Gender :\"+p2);
               //check for female occurance
              if(p1.isFemale())
              {
                  count1++;
              }
              if(p2.isFemale())
              {
                  count2++;
              }
          }
          //display the results
          if(count1==count2)
          System.out.println(\"Tie\");
          else
          if(count1==2)
         System.out.println(\"p1\");
         else if(count2==2)
         System.out.println(\"p2\");
      }
 }
//definitin of Person class
 class Person
 {
     //variable to hold gender
     private int gender;
   
     //dynamiclaly set gender
     public void setGender()
     {
         gender=(int)(Math.random()*2);
     }
   
     //check if gender is female
     public boolean isFemale()
     {
         return (gender==1);
     }
   
     //return gender of person object
     public String toString()
     {
         String genderName;
         if(gender==0)
         genderName=\"Male\";
         else
         genderName=\"Female\";
       
         return genderName;
     }
 }


