import java.util.*;

public class Spy
{
  /*******************************************************
    ** Attributes:
    * name, serialID, rank, enPass, secretPortion, phoenix
    ******************************************************/
  
  //A spy's name
  private String name;
  
  /**
   * A spy's serialID which will have a certain pattern and will be created 
   * in the constructor
   * */
  private long serialID;
  
  
  // A spy's rank (ranging from 1 to 5)
  private int rank;
  
  /**
   * A spy's encoded password.
   * Due to security issues, a spy's password won't be directly stored
   * */
  private String enPass;
  
  //A spy's share of the secret
  private String secretPortion;
  
  /**
   * A string that will be used to ensure that all spies are present.
   * This string will initially be set when all five spy objects
   * are created and will be used to ensure they're all present when
   * it's time to decode the message
   * */
  private static String phoenix = "";
  
  /*********************************************************************
    ** Methods
    *********************************************************************/
  
  /**
   * Constructor
   * 
   * Pre: password is a string only containing characters and no whitespaces
   * Post: An object with the given name and an encoded version of the
   * input password is created. 
   * */
  public Spy(String inputName, String password, int inputRank)
  {
    //Set name and rank appropriately
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
    /**
     * First, convert the string to uppercase and then encode the password 
     * using the encode method (see below)
     * */
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
    
    /**
     * Randomly generate and set the spy's serialID so that it starts with 202
     * and ends with his rank
     * e.g. the first spy's serial ID would be 202**1 where ** can be any
     * digit between 0 and 9
     * */
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
    
    
    /**
     * secretPortion should be set to the spy's share of the secret.
     * We'll use a function called chopMsg (declared below) for this task. Here,
     * set secretPortion to be the output of that function.
     * More specifically, this method breaks the secret into small portions 
     * so that the first spy gets the first fifth, the second spy the 
     * second ..., and the fifth spy the last portion of the secret.
     * */
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
  }
  
  /******************************************
    * Accessor Methods: "Getters" and "Setters"
    *****************************************/
  
  public String getName()
  {
    //Return the value of the name member field
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
  }
  
  public long getID()
  {
    //Return the value of the serialID member field
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
  }
  
  public String getSecretPortion()
  {
    //Return the value of the secretPortion member field
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
  }
  
  public String getEnPass()
  {
    //Return the value of the enPass member field
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
  }
  
  /**
   * Pre: None
   * Post: Use the passwords of all spies collectively, create a string
   * that is the concatenation of their enPasses, encode this string and
   * set phoenix to be this encoded string.
   * */
 
  public static void setPhoenix(String[] input)
  {
    for(int i = 0; i < input.length; i++)
    {
      phoenix +=  input[i];
    }
    phoenix = encode(phoenix);
  }
  
  /**************************************
    ** Cryptography
    ***************************************/
  
  /**
   * Pre: None
   * Post: The input string is encoded using the following simple purmutation 
   * 
   * Encoding scheme:
   * 
   * Divide input into blocks of length six and permute as follows:
   * (where i--> j means that character at position i is swaped with character at 
   * position j)
   *  0 --> 1
   *  1 --> 3
   *  2 --> 5
   *  3 --> 4
   *  4 --> 0
   *  5 --> 2
   *  If a string is not a multiple of six, then append it at the end with character #.
   *  Add the number of padded characters at the beginning of each (permuted) block.
   *  For instance, if there was no padding necessary, then a 0 is appended at the beginning
   *  and if you had to add three #s at the end, then start your encoding with 3 followed by
   *  by the permutation and then the three #s.
   * */
  
  public static String encode(String input)
  {
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
  }
  
  /**
   * Pre: None
   * Post: The input string is decoded using the above permutation scheme:
   * (permutation(permutation msg)) = msg
   * 
   * Decoding scheme:
   *  
   * Divide input into blocks of length seven. The first character of the block will indicate
   * how many padded characters were added. Remove the first character (inicating the number of #'s added), 
   * and then permute as follows:
   * (where i--> j means that character at position i is swaped with character at 
   * position j)
   *  0 --> 4
   *  1 --> 0
   *  2 --> 5
   *  3 --> 1
   *  4 --> 3
   *  5 --> 2
   *  At the last step, remove the #'s from the decoding and append the blocks together.
   * */  
  public static String decode(String input)
  {
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
  }
  
  
  /**
   * Pre: inputID determines the rank of the spy.
   * Post: The master secret is called secret and is stored in Secret.java as a static variable.
   * Chop the encoded secret into five portions and depending on rank, 
   * output the corresponding portion of the encoded secret (i.e. the second spy
   * should receive the second portion of the encoded secret and so on).
   **/
  public String chopMsg()
  {
    
    //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
  }
  
  /**
   * Pre: input is the concatenation of all spies' portion of the messsage
   * Post: If all spies are together and have submitted the correct
   * encoded msg, then display the decoded msg.
   * Note, that this method is called after it's been verified that the 
   * spies are all present.
   * */
  public static String unveilSecret(String input)
  {
     //---------------------------------------//
    //             YOUR CODE GOES HERE       //
    //---------------------------------------//
    
  }
}
