A C D E F G L N P R S T W

A

addVisited(String, int) - Method in class Passport
Add a new entry to the countries visited section of this passport, using the information provided by the user (in the 2 arguments); The new information should be appended to the end of the current variable;

Make sure to preserve the format of this variable, as described above; You can assume that the user will not put in negative integers as the duration.
Also, there must be NO consecutive entries with the same country; if the previous entry has the same country, then the two entries must be merged and their durations added together to form one entry (e.g., "Canada, 10; Canada, 10" should be "Canada, 20").

C

charToBinary(char) - Static method in class Spy
Return the binary representation of character c; You must do this by first converting the character into an integer ASCII value, and then converting that integer into an 8-bit binary value; Note that the return type must be a String of length 8; This means that the ASCII value of the given character cannot be more than 255 -- if the character's ASCII value is greater than 255, then return the empty String ("").
clear() - Method in class Passport
Clear the history of the countries visited for this passport (i.e., make it empty).

D

decrypt(String, int) - Static method in class Spy
Return the decrypted version of the encrypted String, using the given key; You should assume that the String was encrypted using Spy's encrypt method; If the encrypted String is not valid (i.e., it is not composed of 8-bit binary Strings), then return "cannot decrypt".

E

encrypt(String, int) - Static method in class Spy
Return the encrypted version of the msg, using the given key, according to this encryption algorithm.
exclusiveOr(int, int) - Static method in class Spy
Return the result of applying the "exclusive-or" (XOR) operator to integers i and j; You can assume that the input integers will be either 1 or 0, representing true and false, respectively; This means that this method must return either 1 or 0, depending on the result of "i XOR j".

F

firstCountryVisited() - Method in class Passport
Return the first country that the owner of this passport has visited, or empty string ("") if no countries have been visited.

G

getAllCodeNumbers() - Static method in class Spy
Return the code numbers of all existing Spies.
getCodeNumber() - Method in class Spy
Return the secret code number of this Spy.
getCountriesVisited() - Method in class Passport
Return the countries visited section of this passport.
getName() - Method in class Passport
Return the name of this passport's owner.
getSerialNumber() - Method in class Passport
Return the serial number of this passport.

L

lastCountryVisited() - Method in class Passport
Return the last country that the owner of this passport has visited, or empty string ("") if no countries have been visited.
longestVisitedCountry() - Method in class Passport
Return the country that the owner of this passport has visited for the longest duration, or empty string ("") if no countries have been visited;
If there is a tie between two or more countries, return the most recent of these countries (i.e., the first one from the right of the String variable).

N

numEntries() - Method in class Passport
Return the total number of entries in this passport's countries visited section; You must count every entry, including multiple visits to the same country.
numVisits(String) - Method in class Passport
Return the number of times this passport's owner has visited the country specified by the user.

P

Passport - Class in <Unnamed>
The Passport class is a simplified representation of a real passport.
Passport(String, int) - Constructor for class Passport
Create a new passport with name n, serial number s, and no countries visited.

R

removeCodeNumber(int) - Static method in class Spy
Remove the specified code number c from the record of all existing code numbers; Return true once this is done; if the specified code number does not exist in the record, return false.

S

Spy - Class in <Unnamed>
The Spy class contains methods to encrypt and decrypt messages, as well as information about the secret code names of Spies that are already operating.
Spy(int) - Constructor for class Spy
Create a new Spy with code number n; Update the record of all existing code numbers according to the description above; If the specified code number already exists in the record, print a warning message to the user (hint: use System.out.println); You can assume that the user's input will be a 4-digit integer.
stretch(String, int) - Static method in class Spy
Return a new key that is the result of stretching the given binKey to be AT LEAST as long as the given length; The given binKey must be a String of bits!

The algorithm for this "stretching" is as follows: divide the binary key into two even halves (you can assume that the key has an even number of bits), then XOR the corresponding bits of each half to produce a new String of bits, and append this new String of bits to the end of the key; If the resulting key is still not as long as the given length, then repeat the process until the key is at least as long as the given length.

T

toString() - Method in class Passport
Return the information about this passport as a String in the following format (3 lines; there must be one space after the first ":" on each line):

Name: n
Serial Number: s
Countries Visited: cv

where n is the name of this passport's owner, s is the serial number of this passport, and cv is this passport's record of countries visited (along with the durations);
If no countries have been visited, then the value of cv must be the String "none".
totalDuration(String) - Method in class Passport
Return the total number of days that the owner of this passport spent in the specified country.

W

whichCountryVisited(int) - Method in class Passport
Return the country that the owner of this passport visited at the specified index -- which starts at 1 (not zero!);
If the user specified an invalid index (i.e., less than 1 or greater than the number of entries), then return the String: "Invalid index!"
(it's important that the String be EXACTLY like this, with the capital I at the beginning and ! at the end).

A C D E F G L N P R S T W