Rename 'CT326_Programming_III' to 'CT326: Programming III'

This commit is contained in:
2023-12-09 16:50:55 +00:00
parent a7e7f78f52
commit 066ec2d356
193 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>CT326-Assignment3</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,81 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.time.LocalDate;
/**
* class representing a player's achievement
*/
public class Achievement {
private String achievementName;
private String description;
private LocalDate dateOfAward;
/**
* constructor for the Achievement class
* @param achievementName a String representation of the name of the Achievement
* @param description a String describing the Achievement
* @param dateOfAward a LocalDate representing the date that the Achievement was awarded
*/
public Achievement(String achievementName, String description, LocalDate dateOfAward) {
this.achievementName = achievementName;
this.description = description;
this.dateOfAward = dateOfAward;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Achievement) {
Achievement toCompare = (Achievement) obj;
if (!achievementName.equals(toCompare.achievementName)) {
return false;
}
if (!description.equals(toCompare.description)) {
return false;
}
if (!dateOfAward.equals(toCompare.dateOfAward)) {
return false;
}
return true;
}
else { return false; }
}
/**
* getter method for the achievementName field
* @return a String representation of the name of the Achievement
*/
public String getAchievementName() { return achievementName; }
/**
* setter method for the achievementName field
* @param achievementName a String representation of the name of the Achievement
*/
public void setAchievementName(String achievementName) { this.achievementName = achievementName; }
/**
* getter method for the description field
* @return a String describing the Achievement
*/
public String getDescription() { return description; }
/**
* setter method for the description field
* @param description a String describing the Achievement
*/
public void setDescription(String description) { this.description = description; }
/**
* getter method for the dateOfAward field
* @return a LocalDate representing the date that the Achievement was awarded
*/
public LocalDate getDateOfAward() { return dateOfAward; }
/**
* setter method for the dateOfAward field
* @param dateOfAward a LocalDate representing the date that the Achievement was awarded
*/
public void setDateOfAward(LocalDate dateOfAward) { this.dateOfAward = dateOfAward; }
}

View File

@ -0,0 +1,260 @@
/**
* enum for each ISO 3166 Alpha-2 country Code
*/
public enum Country {
// Explanation of how this data was sourced:
// the following ISO 3166 Alpha-2 Codes were taken from the CSV file found here: https://pkgstore.datahub.io/core/country-list/data_csv/data/d7c9d7cfb42cb69f4422dec222dbbaa8/data_csv.csv
// the CSV file was cleaned to have UNIX line endings (as it had Windows line endings, and I am on GNU/Linux) with the command `tr -d '\r' < data_csv.csv > clean_data.csv `
// they were then parsed & read into this Java source file with the Vim / GNU AWK command `:read !awk -F',' '{gsub(/\"/, ""); print $NF ",\t// " $1}' clean_data.csv`
// finally, the block was indented in Vim and a `;` appended to the last value
AF, // Afghanistan
AX, // Åland Islands
AL, // Albania
DZ, // Algeria
AS, // American Samoa
AD, // Andorra
AO, // Angola
AI, // Anguilla
AQ, // Antarctica
AG, // Antigua and Barbuda
AR, // Argentina
AM, // Armenia
AW, // Aruba
AU, // Australia
AT, // Austria
AZ, // Azerbaijan
BS, // Bahamas
BH, // Bahrain
BD, // Bangladesh
BB, // Barbados
BY, // Belarus
BE, // Belgium
BZ, // Belize
BJ, // Benin
BM, // Bermuda
BT, // Bhutan
BO, // Bolivia
BQ, // Bonaire
BA, // Bosnia and Herzegovina
BW, // Botswana
BV, // Bouvet Island
BR, // Brazil
IO, // British Indian Ocean Territory
BN, // Brunei Darussalam
BG, // Bulgaria
BF, // Burkina Faso
BI, // Burundi
KH, // Cambodia
CM, // Cameroon
CA, // Canada
CV, // Cape Verde
KY, // Cayman Islands
CF, // Central African Republic
TD, // Chad
CL, // Chile
CN, // China
CX, // Christmas Island
CC, // Cocos (Keeling) Islands
CO, // Colombia
KM, // Comoros
CG, // Congo
CD, // Congo
CK, // Cook Islands
CR, // Costa Rica
CI, // Côte d'Ivoire
HR, // Croatia
CU, // Cuba
CW, // Curaçao
CY, // Cyprus
CZ, // Czech Republic
DK, // Denmark
DJ, // Djibouti
DM, // Dominica
DO, // Dominican Republic
EC, // Ecuador
EG, // Egypt
SV, // El Salvador
GQ, // Equatorial Guinea
ER, // Eritrea
EE, // Estonia
ET, // Ethiopia
FK, // Falkland Islands (Malvinas)
FO, // Faroe Islands
FJ, // Fiji
FI, // Finland
FR, // France
GF, // French Guiana
PF, // French Polynesia
TF, // French Southern Territories
GA, // Gabon
GM, // Gambia
GE, // Georgia
DE, // Germany
GH, // Ghana
GI, // Gibraltar
GR, // Greece
GL, // Greenland
GD, // Grenada
GP, // Guadeloupe
GU, // Guam
GT, // Guatemala
GG, // Guernsey
GN, // Guinea
GW, // Guinea-Bissau
GY, // Guyana
HT, // Haiti
HM, // Heard Island and McDonald Islands
VA, // Holy See (Vatican City State)
HN, // Honduras
HK, // Hong Kong
HU, // Hungary
IS, // Iceland
IN, // India
ID, // Indonesia
IR, // Iran
IQ, // Iraq
IE, // Ireland
IM, // Isle of Man
IL, // Israel
IT, // Italy
JM, // Jamaica
JP, // Japan
JE, // Jersey
JO, // Jordan
KZ, // Kazakhstan
KE, // Kenya
KI, // Kiribati
KP, // Korea
KR, // Korea
KW, // Kuwait
KG, // Kyrgyzstan
LA, // Lao People's Democratic Republic
LV, // Latvia
LB, // Lebanon
LS, // Lesotho
LR, // Liberia
LY, // Libya
LI, // Liechtenstein
LT, // Lithuania
LU, // Luxembourg
MO, // Macao
MK, // Macedonia
MG, // Madagascar
MW, // Malawi
MY, // Malaysia
MV, // Maldives
ML, // Mali
MT, // Malta
MH, // Marshall Islands
MQ, // Martinique
MR, // Mauritania
MU, // Mauritius
YT, // Mayotte
MX, // Mexico
FM, // Micronesia
MD, // Moldova
MC, // Monaco
MN, // Mongolia
ME, // Montenegro
MS, // Montserrat
MA, // Morocco
MZ, // Mozambique
MM, // Myanmar
NA, // Namibia
NR, // Nauru
NP, // Nepal
NL, // Netherlands
NC, // New Caledonia
NZ, // New Zealand
NI, // Nicaragua
NE, // Niger
NG, // Nigeria
NU, // Niue
NF, // Norfolk Island
MP, // Northern Mariana Islands
NO, // Norway
OM, // Oman
PK, // Pakistan
PW, // Palau
PS, // Palestine
PA, // Panama
PG, // Papua New Guinea
PY, // Paraguay
PE, // Peru
PH, // Philippines
PN, // Pitcairn
PL, // Poland
PT, // Portugal
PR, // Puerto Rico
QA, // Qatar
RE, // Réunion
RO, // Romania
RU, // Russian Federation
RW, // Rwanda
BL, // Saint Barthélemy
SH, // Saint Helena
KN, // Saint Kitts and Nevis
LC, // Saint Lucia
MF, // Saint Martin (French part)
PM, // Saint Pierre and Miquelon
VC, // Saint Vincent and the Grenadines
WS, // Samoa
SM, // San Marino
ST, // Sao Tome and Principe
SA, // Saudi Arabia
SN, // Senegal
RS, // Serbia
SC, // Seychelles
SL, // Sierra Leone
SG, // Singapore
SX, // Sint Maarten (Dutch part)
SK, // Slovakia
SI, // Slovenia
SB, // Solomon Islands
SO, // Somalia
ZA, // South Africa
GS, // South Georgia and the South Sandwich Islands
SS, // South Sudan
ES, // Spain
LK, // Sri Lanka
SD, // Sudan
SR, // Suriname
SJ, // Svalbard and Jan Mayen
SZ, // Swaziland
SE, // Sweden
CH, // Switzerland
SY, // Syrian Arab Republic
TW, // Taiwan
TJ, // Tajikistan
TZ, // Tanzania
TH, // Thailand
TL, // Timor-Leste
TG, // Togo
TK, // Tokelau
TO, // Tonga
TT, // Trinidad and Tobago
TN, // Tunisia
TR, // Turkey
TM, // Turkmenistan
TC, // Turks and Caicos Islands
TV, // Tuvalu
UG, // Uganda
UA, // Ukraine
AE, // United Arab Emirates
GB, // United Kingdom
US, // United States
UM, // United States Minor Outlying Islands
UY, // Uruguay
UZ, // Uzbekistan
VU, // Vanuatu
VE, // Venezuela
VN, // Viet Nam
VG, // Virgin Islands
VI, // Virgin Islands
WF, // Wallis and Futuna
EH, // Western Sahara
YE, // Yemen
ZM, // Zambia
ZW; // Zimbabwe
}

View File

@ -0,0 +1,184 @@
import java.io.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* class to represent a player
*/
public class Player implements Serializable {
private String id;
private String username;
private Country country;
private LocalDate joinDate;
private List<Achievement> achievements;
private static final String serializeAchievementsTo = "achievements.csv";
/**
* constructor for the Player class
* @param id a String representing the player's ID
* @param username a String representing the player's username
* @param country a Country object representing the country to which the player belongs
* @param joinDate a LocalDate object representing the date that the player joined the team
* @param achievements a List of Achievement objects awarded to the player
*/
public Player(String id, String username, Country country, LocalDate joinDate, List<Achievement> achievements) {
this.id = id;
this.username = username;
this.country = country;
this.joinDate = joinDate;
this.achievements = achievements;
}
/**
* overridden method to compare two objects for equality
* @param obj the object to be compared
* @return boolean - true if the objects have all the same fields equals, false otherwise
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof Player) {
Player toCompare = (Player) obj;
if (!id.equals(toCompare.id)) {
return false;
}
if (!username.equals(toCompare.username)) {
return false;
}
if (!country.equals(toCompare.country)) {
return false;
}
if (!joinDate.equals(toCompare.joinDate)) {
return false;
}
if (!achievements.equals(toCompare.achievements)) {
return false;
} // note that if the lists are in different orders, this will return false
return true;
}
else { return false; }
}
/**
* method to deserialize the Player object and to read in its achievements from a CSV file
* @param out ObjectOutputStream
* @throws IOException
*/
@Serial
private void writeObject(ObjectOutputStream out) throws IOException {
// would be inappropriate to catch IOExceptions here - should be caught in the code attempting to serialize the object
out.writeObject(id);
out.writeObject(username);
out.writeObject(country);
out.writeObject(joinDate);
// deliberate design choice here to not use the writeObject method of the Achievement class
// serializing Achievements in the context of a Player's list of Achievements should be treated differently to serializing, say, a single, isolated Achievement
// there may be times when we want to serialize an Achievement without reference to a Player, without a CSV file
// writing out Achievements to CSV file
FileWriter writer = new FileWriter(serializeAchievementsTo, true); // append set to true
for (Achievement achievement : achievements) {
writer.write(id + "," + achievement.getAchievementName() + "," + achievement.getDescription() + "," + achievement.getDateOfAward().toString() + "\n");
}
writer.close();
}
/**
* method to serialize the Player object and to write out its achievements to a CSV file
* @param in ObjectInputStream
* @throws IOException
* @throws ClassNotFoundException
*/
@Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
// would be inappropriate to catch exceptions here - should be caught in the code attempting to de-serialize the object
id = (String) in.readObject();
username = (String) in.readObject();
country = (Country) in.readObject();
joinDate = (LocalDate) in.readObject();
achievements = new ArrayList<>();
FileReader fileReader = new FileReader(serializeAchievementsTo);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
String[] cols = line.split(",");
// only adding to list of achievements if the player ids match
if (cols[0].equals(id)) {
achievements.add(new Achievement(cols[1], cols[2], LocalDate.parse(cols[3], DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
}
}
bufferedReader.close();
}
/**
* getter method for the ID field
* @return a String representing the player's ID
*/
public String getId() { return id; }
/**
* setter method for the id field
* @param id String representing the player's ID
*/
public void setId(String id) { this.id = id; }
/**
* getter method for the username field
* @return a String representing the player's username
*/
public String getUsername() { return username; }
/**
* setter method for the username field
* @param username String representing the player's username
*/
public void setUsername(String username) { this.username = username; }
/**
* getter method for the country field
* @return a Country object
*/
public Country getCountry() { return country; }
/**
* setter method for the country field
* @param country a Country object
*/
public void setCountry(Country country) { this.country = country; }
/**
* getter method for the joinDate field
* @return a LocalDate representing the date when the player joined the team
*/
public LocalDate getJoinDate() { return joinDate; }
/**
* setter method for the joinDate field
* @param joinDate LocalDate representing the date when the player joined the team
*/
public void setJoinDate(LocalDate joinDate) { this.joinDate = joinDate; }
/**
* getter method for the achievements field
* @return a list of Achievement objects
*/
public List<Achievement> getAchievements() { return achievements; }
/**
* setter method for the achievements field
* @param achievements a list of Achievement objects
*/
public void setAchievements(List<Achievement> achievements) { this.achievements = achievements; }
}

View File

@ -0,0 +1,155 @@
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.*;
import java.io.*;
import java.time.LocalDate;
import java.util.ArrayList;
/**
* JUnit tests to test the serialization ability of the Player class
*/
public class TestSerialization {
// assuming that the instruction "Use a test-driven development approach to implement the serialization of Player objects" only applies to the serialization, and not the other functionality
/**
* method that runs after each test and deletes the achievements.csv and players.ser files
*/
@AfterEach
void deleteFiles() {
File achievementsFile = new File("achievements.csv");
achievementsFile.delete();
File playersFile = new File("player.ser");
playersFile.delete();
}
/**
* test that creates 5 player objects, serializes them, and compares them to the deserialized objects
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
void serializeFivePlayers() throws IOException, ClassNotFoundException {
// deliberately not catching potential IOExceptions - we want the tests to fail if these are thrown
FileOutputStream players_file = new FileOutputStream("players.ser");
ObjectOutputStream players_out = new ObjectOutputStream(players_file);
ObjectInputStream players_in = new ObjectInputStream(new FileInputStream("players.ser"));
ArrayList<Player> players = new ArrayList<>(); // array of players to be serialized
// creating some unique players
// player 0
players.add(new Player("0", "player0", Country.IE, LocalDate.now(),
new ArrayList<>() {{
add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6)));
}}
));
// player 1
players.add(new Player("1", "player1", Country.JP, LocalDate.now(),
new ArrayList<>() {{
add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6)));
add(new Achievement("Another Award", "An award for something else", LocalDate.of(1996, 7, 6)));
}}
));
// player 2
players.add(new Player("2", "player2", Country.UA, LocalDate.now(),
new ArrayList<>() {{
add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6)));
add(new Achievement("Another Award", "An award for something else", LocalDate.of(1996, 7, 6)));
add(new Achievement("Yet Another Award", "An award for something else entirely", LocalDate.of(2023, 8, 6)));
}}
));
// player 3
players.add(new Player("3", "player3", Country.AD, LocalDate.now(),
new ArrayList<>() {{
add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6)));
add(new Achievement("Another Award", "An award for something else", LocalDate.of(1996, 7, 6)));
add(new Achievement("Yet Another Award", "An award for something else entirely", LocalDate.of(2023, 8, 6)));
add(new Achievement("A fourth award", "An award that comes after three previous awards", LocalDate.of(2022, 8, 3)));
}}
));
// player 4
players.add(new Player("4", "player4", Country.DE, LocalDate.now(),
new ArrayList<>() {{
add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6)));
add(new Achievement("Another Award", "An award for something else", LocalDate.of(1996, 7, 6)));
add(new Achievement("Yet Another Award", "An award for something else entirely", LocalDate.of(2023, 8, 6)));
add(new Achievement("A fourth award", "An award that comes after three previous awards", LocalDate.of(2022, 8, 3)));
add(new Achievement("The final award", "The last award anyone will ever get", LocalDate.of(2030, 12, 25)));
}}
));
for (Player player : players) {
players_out.writeObject(player);
}
// looping over each player and comparing it to the de-serialized player
// doing this in a separate loop to separate writing and reading
for (Player player : players) {
// deliberately not catching exceptions here - we want the test to fail if exceptions are thrown
Player dplayer = (Player) players_in.readObject();
assertEquals(player, dplayer);
}
players_out.close();
players_file.close();
}
/**
* test the equals() method of the Player class
*/
@Test
void testPlayerDotEquals() {
// creating two identical players
Player player1 = new Player("0", "player0", Country.IE, LocalDate.now(),
new ArrayList<>(){{ add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6))); }}
);
Player player2 = new Player("0", "player0", Country.IE, LocalDate.now(),
new ArrayList<>(){{ add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6))); }}
);
// assertEquals uses the objects equals() method, so it suffices for this test
assertEquals(player1, player2);
}
/**
* test the equals() method of the Achievement class
*/
@Test
void testAchievementDotEquals() {
Achievement achievement1 = new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6));
Achievement achievement2 = new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6));
assertEquals(achievement1, achievement2);
}
/**
* test serializing & de-serializing just one player
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
void testSerializePlayer() throws IOException, ClassNotFoundException {
// deliberately not catching potential IOExceptions - we want the tests to fail if these are thrown
FileOutputStream players_file = new FileOutputStream("players.ser");
ObjectOutputStream players_out = new ObjectOutputStream(players_file);
ObjectInputStream players_in = new ObjectInputStream(new FileInputStream("players.ser"));
Player player = new Player("0", "player0", Country.IE, LocalDate.now(),
new ArrayList<>(){{ add(new Achievement("Something Award", "An award for something that was especially something", LocalDate.of(2004, 7, 6))); }}
);
// serializing player object, de-serializing it, and comparing them
players_out.writeObject(player);
Player dplayer = (Player) players_in.readObject();
players_out.close();
players_file.close();
assertEquals(player, dplayer);
}
}

View File

@ -0,0 +1,250 @@
Name,Code
Afghanistan,AF
Åland Islands,AX
Albania,AL
Algeria,DZ
American Samoa,AS
Andorra,AD
Angola,AO
Anguilla,AI
Antarctica,AQ
Antigua and Barbuda,AG
Argentina,AR
Armenia,AM
Aruba,AW
Australia,AU
Austria,AT
Azerbaijan,AZ
Bahamas,BS
Bahrain,BH
Bangladesh,BD
Barbados,BB
Belarus,BY
Belgium,BE
Belize,BZ
Benin,BJ
Bermuda,BM
Bhutan,BT
"Bolivia, Plurinational State of",BO
"Bonaire, Sint Eustatius and Saba",BQ
Bosnia and Herzegovina,BA
Botswana,BW
Bouvet Island,BV
Brazil,BR
British Indian Ocean Territory,IO
Brunei Darussalam,BN
Bulgaria,BG
Burkina Faso,BF
Burundi,BI
Cambodia,KH
Cameroon,CM
Canada,CA
Cape Verde,CV
Cayman Islands,KY
Central African Republic,CF
Chad,TD
Chile,CL
China,CN
Christmas Island,CX
Cocos (Keeling) Islands,CC
Colombia,CO
Comoros,KM
Congo,CG
"Congo, the Democratic Republic of the",CD
Cook Islands,CK
Costa Rica,CR
Côte d'Ivoire,CI
Croatia,HR
Cuba,CU
Curaçao,CW
Cyprus,CY
Czech Republic,CZ
Denmark,DK
Djibouti,DJ
Dominica,DM
Dominican Republic,DO
Ecuador,EC
Egypt,EG
El Salvador,SV
Equatorial Guinea,GQ
Eritrea,ER
Estonia,EE
Ethiopia,ET
Falkland Islands (Malvinas),FK
Faroe Islands,FO
Fiji,FJ
Finland,FI
France,FR
French Guiana,GF
French Polynesia,PF
French Southern Territories,TF
Gabon,GA
Gambia,GM
Georgia,GE
Germany,DE
Ghana,GH
Gibraltar,GI
Greece,GR
Greenland,GL
Grenada,GD
Guadeloupe,GP
Guam,GU
Guatemala,GT
Guernsey,GG
Guinea,GN
Guinea-Bissau,GW
Guyana,GY
Haiti,HT
Heard Island and McDonald Islands,HM
Holy See (Vatican City State),VA
Honduras,HN
Hong Kong,HK
Hungary,HU
Iceland,IS
India,IN
Indonesia,ID
"Iran, Islamic Republic of",IR
Iraq,IQ
Ireland,IE
Isle of Man,IM
Israel,IL
Italy,IT
Jamaica,JM
Japan,JP
Jersey,JE
Jordan,JO
Kazakhstan,KZ
Kenya,KE
Kiribati,KI
"Korea, Democratic People's Republic of",KP
"Korea, Republic of",KR
Kuwait,KW
Kyrgyzstan,KG
Lao People's Democratic Republic,LA
Latvia,LV
Lebanon,LB
Lesotho,LS
Liberia,LR
Libya,LY
Liechtenstein,LI
Lithuania,LT
Luxembourg,LU
Macao,MO
"Macedonia, the Former Yugoslav Republic of",MK
Madagascar,MG
Malawi,MW
Malaysia,MY
Maldives,MV
Mali,ML
Malta,MT
Marshall Islands,MH
Martinique,MQ
Mauritania,MR
Mauritius,MU
Mayotte,YT
Mexico,MX
"Micronesia, Federated States of",FM
"Moldova, Republic of",MD
Monaco,MC
Mongolia,MN
Montenegro,ME
Montserrat,MS
Morocco,MA
Mozambique,MZ
Myanmar,MM
Namibia,NA
Nauru,NR
Nepal,NP
Netherlands,NL
New Caledonia,NC
New Zealand,NZ
Nicaragua,NI
Niger,NE
Nigeria,NG
Niue,NU
Norfolk Island,NF
Northern Mariana Islands,MP
Norway,NO
Oman,OM
Pakistan,PK
Palau,PW
"Palestine, State of",PS
Panama,PA
Papua New Guinea,PG
Paraguay,PY
Peru,PE
Philippines,PH
Pitcairn,PN
Poland,PL
Portugal,PT
Puerto Rico,PR
Qatar,QA
Réunion,RE
Romania,RO
Russian Federation,RU
Rwanda,RW
Saint Barthélemy,BL
"Saint Helena, Ascension and Tristan da Cunha",SH
Saint Kitts and Nevis,KN
Saint Lucia,LC
Saint Martin (French part),MF
Saint Pierre and Miquelon,PM
Saint Vincent and the Grenadines,VC
Samoa,WS
San Marino,SM
Sao Tome and Principe,ST
Saudi Arabia,SA
Senegal,SN
Serbia,RS
Seychelles,SC
Sierra Leone,SL
Singapore,SG
Sint Maarten (Dutch part),SX
Slovakia,SK
Slovenia,SI
Solomon Islands,SB
Somalia,SO
South Africa,ZA
South Georgia and the South Sandwich Islands,GS
South Sudan,SS
Spain,ES
Sri Lanka,LK
Sudan,SD
Suriname,SR
Svalbard and Jan Mayen,SJ
Swaziland,SZ
Sweden,SE
Switzerland,CH
Syrian Arab Republic,SY
"Taiwan, Province of China",TW
Tajikistan,TJ
"Tanzania, United Republic of",TZ
Thailand,TH
Timor-Leste,TL
Togo,TG
Tokelau,TK
Tonga,TO
Trinidad and Tobago,TT
Tunisia,TN
Turkey,TR
Turkmenistan,TM
Turks and Caicos Islands,TC
Tuvalu,TV
Uganda,UG
Ukraine,UA
United Arab Emirates,AE
United Kingdom,GB
United States,US
United States Minor Outlying Islands,UM
Uruguay,UY
Uzbekistan,UZ
Vanuatu,VU
"Venezuela, Bolivarian Republic of",VE
Viet Nam,VN
"Virgin Islands, British",VG
"Virgin Islands, U.S.",VI
Wallis and Futuna,WF
Western Sahara,EH
Yemen,YE
Zambia,ZM
Zimbabwe,ZW
1 Name Code
2 Afghanistan AF
3 Åland Islands AX
4 Albania AL
5 Algeria DZ
6 American Samoa AS
7 Andorra AD
8 Angola AO
9 Anguilla AI
10 Antarctica AQ
11 Antigua and Barbuda AG
12 Argentina AR
13 Armenia AM
14 Aruba AW
15 Australia AU
16 Austria AT
17 Azerbaijan AZ
18 Bahamas BS
19 Bahrain BH
20 Bangladesh BD
21 Barbados BB
22 Belarus BY
23 Belgium BE
24 Belize BZ
25 Benin BJ
26 Bermuda BM
27 Bhutan BT
28 Bolivia, Plurinational State of BO
29 Bonaire, Sint Eustatius and Saba BQ
30 Bosnia and Herzegovina BA
31 Botswana BW
32 Bouvet Island BV
33 Brazil BR
34 British Indian Ocean Territory IO
35 Brunei Darussalam BN
36 Bulgaria BG
37 Burkina Faso BF
38 Burundi BI
39 Cambodia KH
40 Cameroon CM
41 Canada CA
42 Cape Verde CV
43 Cayman Islands KY
44 Central African Republic CF
45 Chad TD
46 Chile CL
47 China CN
48 Christmas Island CX
49 Cocos (Keeling) Islands CC
50 Colombia CO
51 Comoros KM
52 Congo CG
53 Congo, the Democratic Republic of the CD
54 Cook Islands CK
55 Costa Rica CR
56 Côte d'Ivoire CI
57 Croatia HR
58 Cuba CU
59 Curaçao CW
60 Cyprus CY
61 Czech Republic CZ
62 Denmark DK
63 Djibouti DJ
64 Dominica DM
65 Dominican Republic DO
66 Ecuador EC
67 Egypt EG
68 El Salvador SV
69 Equatorial Guinea GQ
70 Eritrea ER
71 Estonia EE
72 Ethiopia ET
73 Falkland Islands (Malvinas) FK
74 Faroe Islands FO
75 Fiji FJ
76 Finland FI
77 France FR
78 French Guiana GF
79 French Polynesia PF
80 French Southern Territories TF
81 Gabon GA
82 Gambia GM
83 Georgia GE
84 Germany DE
85 Ghana GH
86 Gibraltar GI
87 Greece GR
88 Greenland GL
89 Grenada GD
90 Guadeloupe GP
91 Guam GU
92 Guatemala GT
93 Guernsey GG
94 Guinea GN
95 Guinea-Bissau GW
96 Guyana GY
97 Haiti HT
98 Heard Island and McDonald Islands HM
99 Holy See (Vatican City State) VA
100 Honduras HN
101 Hong Kong HK
102 Hungary HU
103 Iceland IS
104 India IN
105 Indonesia ID
106 Iran, Islamic Republic of IR
107 Iraq IQ
108 Ireland IE
109 Isle of Man IM
110 Israel IL
111 Italy IT
112 Jamaica JM
113 Japan JP
114 Jersey JE
115 Jordan JO
116 Kazakhstan KZ
117 Kenya KE
118 Kiribati KI
119 Korea, Democratic People's Republic of KP
120 Korea, Republic of KR
121 Kuwait KW
122 Kyrgyzstan KG
123 Lao People's Democratic Republic LA
124 Latvia LV
125 Lebanon LB
126 Lesotho LS
127 Liberia LR
128 Libya LY
129 Liechtenstein LI
130 Lithuania LT
131 Luxembourg LU
132 Macao MO
133 Macedonia, the Former Yugoslav Republic of MK
134 Madagascar MG
135 Malawi MW
136 Malaysia MY
137 Maldives MV
138 Mali ML
139 Malta MT
140 Marshall Islands MH
141 Martinique MQ
142 Mauritania MR
143 Mauritius MU
144 Mayotte YT
145 Mexico MX
146 Micronesia, Federated States of FM
147 Moldova, Republic of MD
148 Monaco MC
149 Mongolia MN
150 Montenegro ME
151 Montserrat MS
152 Morocco MA
153 Mozambique MZ
154 Myanmar MM
155 Namibia NA
156 Nauru NR
157 Nepal NP
158 Netherlands NL
159 New Caledonia NC
160 New Zealand NZ
161 Nicaragua NI
162 Niger NE
163 Nigeria NG
164 Niue NU
165 Norfolk Island NF
166 Northern Mariana Islands MP
167 Norway NO
168 Oman OM
169 Pakistan PK
170 Palau PW
171 Palestine, State of PS
172 Panama PA
173 Papua New Guinea PG
174 Paraguay PY
175 Peru PE
176 Philippines PH
177 Pitcairn PN
178 Poland PL
179 Portugal PT
180 Puerto Rico PR
181 Qatar QA
182 Réunion RE
183 Romania RO
184 Russian Federation RU
185 Rwanda RW
186 Saint Barthélemy BL
187 Saint Helena, Ascension and Tristan da Cunha SH
188 Saint Kitts and Nevis KN
189 Saint Lucia LC
190 Saint Martin (French part) MF
191 Saint Pierre and Miquelon PM
192 Saint Vincent and the Grenadines VC
193 Samoa WS
194 San Marino SM
195 Sao Tome and Principe ST
196 Saudi Arabia SA
197 Senegal SN
198 Serbia RS
199 Seychelles SC
200 Sierra Leone SL
201 Singapore SG
202 Sint Maarten (Dutch part) SX
203 Slovakia SK
204 Slovenia SI
205 Solomon Islands SB
206 Somalia SO
207 South Africa ZA
208 South Georgia and the South Sandwich Islands GS
209 South Sudan SS
210 Spain ES
211 Sri Lanka LK
212 Sudan SD
213 Suriname SR
214 Svalbard and Jan Mayen SJ
215 Swaziland SZ
216 Sweden SE
217 Switzerland CH
218 Syrian Arab Republic SY
219 Taiwan, Province of China TW
220 Tajikistan TJ
221 Tanzania, United Republic of TZ
222 Thailand TH
223 Timor-Leste TL
224 Togo TG
225 Tokelau TK
226 Tonga TO
227 Trinidad and Tobago TT
228 Tunisia TN
229 Turkey TR
230 Turkmenistan TM
231 Turks and Caicos Islands TC
232 Tuvalu TV
233 Uganda UG
234 Ukraine UA
235 United Arab Emirates AE
236 United Kingdom GB
237 United States US
238 United States Minor Outlying Islands UM
239 Uruguay UY
240 Uzbekistan UZ
241 Vanuatu VU
242 Venezuela, Bolivarian Republic of VE
243 Viet Nam VN
244 Virgin Islands, British VG
245 Virgin Islands, U.S. VI
246 Wallis and Futuna WF
247 Western Sahara EH
248 Yemen YE
249 Zambia ZM
250 Zimbabwe ZW

View File

@ -0,0 +1,250 @@
Name,Code
Afghanistan,AF
Åland Islands,AX
Albania,AL
Algeria,DZ
American Samoa,AS
Andorra,AD
Angola,AO
Anguilla,AI
Antarctica,AQ
Antigua and Barbuda,AG
Argentina,AR
Armenia,AM
Aruba,AW
Australia,AU
Austria,AT
Azerbaijan,AZ
Bahamas,BS
Bahrain,BH
Bangladesh,BD
Barbados,BB
Belarus,BY
Belgium,BE
Belize,BZ
Benin,BJ
Bermuda,BM
Bhutan,BT
"Bolivia, Plurinational State of",BO
"Bonaire, Sint Eustatius and Saba",BQ
Bosnia and Herzegovina,BA
Botswana,BW
Bouvet Island,BV
Brazil,BR
British Indian Ocean Territory,IO
Brunei Darussalam,BN
Bulgaria,BG
Burkina Faso,BF
Burundi,BI
Cambodia,KH
Cameroon,CM
Canada,CA
Cape Verde,CV
Cayman Islands,KY
Central African Republic,CF
Chad,TD
Chile,CL
China,CN
Christmas Island,CX
Cocos (Keeling) Islands,CC
Colombia,CO
Comoros,KM
Congo,CG
"Congo, the Democratic Republic of the",CD
Cook Islands,CK
Costa Rica,CR
Côte d'Ivoire,CI
Croatia,HR
Cuba,CU
Curaçao,CW
Cyprus,CY
Czech Republic,CZ
Denmark,DK
Djibouti,DJ
Dominica,DM
Dominican Republic,DO
Ecuador,EC
Egypt,EG
El Salvador,SV
Equatorial Guinea,GQ
Eritrea,ER
Estonia,EE
Ethiopia,ET
Falkland Islands (Malvinas),FK
Faroe Islands,FO
Fiji,FJ
Finland,FI
France,FR
French Guiana,GF
French Polynesia,PF
French Southern Territories,TF
Gabon,GA
Gambia,GM
Georgia,GE
Germany,DE
Ghana,GH
Gibraltar,GI
Greece,GR
Greenland,GL
Grenada,GD
Guadeloupe,GP
Guam,GU
Guatemala,GT
Guernsey,GG
Guinea,GN
Guinea-Bissau,GW
Guyana,GY
Haiti,HT
Heard Island and McDonald Islands,HM
Holy See (Vatican City State),VA
Honduras,HN
Hong Kong,HK
Hungary,HU
Iceland,IS
India,IN
Indonesia,ID
"Iran, Islamic Republic of",IR
Iraq,IQ
Ireland,IE
Isle of Man,IM
Israel,IL
Italy,IT
Jamaica,JM
Japan,JP
Jersey,JE
Jordan,JO
Kazakhstan,KZ
Kenya,KE
Kiribati,KI
"Korea, Democratic People's Republic of",KP
"Korea, Republic of",KR
Kuwait,KW
Kyrgyzstan,KG
Lao People's Democratic Republic,LA
Latvia,LV
Lebanon,LB
Lesotho,LS
Liberia,LR
Libya,LY
Liechtenstein,LI
Lithuania,LT
Luxembourg,LU
Macao,MO
"Macedonia, the Former Yugoslav Republic of",MK
Madagascar,MG
Malawi,MW
Malaysia,MY
Maldives,MV
Mali,ML
Malta,MT
Marshall Islands,MH
Martinique,MQ
Mauritania,MR
Mauritius,MU
Mayotte,YT
Mexico,MX
"Micronesia, Federated States of",FM
"Moldova, Republic of",MD
Monaco,MC
Mongolia,MN
Montenegro,ME
Montserrat,MS
Morocco,MA
Mozambique,MZ
Myanmar,MM
Namibia,NA
Nauru,NR
Nepal,NP
Netherlands,NL
New Caledonia,NC
New Zealand,NZ
Nicaragua,NI
Niger,NE
Nigeria,NG
Niue,NU
Norfolk Island,NF
Northern Mariana Islands,MP
Norway,NO
Oman,OM
Pakistan,PK
Palau,PW
"Palestine, State of",PS
Panama,PA
Papua New Guinea,PG
Paraguay,PY
Peru,PE
Philippines,PH
Pitcairn,PN
Poland,PL
Portugal,PT
Puerto Rico,PR
Qatar,QA
Réunion,RE
Romania,RO
Russian Federation,RU
Rwanda,RW
Saint Barthélemy,BL
"Saint Helena, Ascension and Tristan da Cunha",SH
Saint Kitts and Nevis,KN
Saint Lucia,LC
Saint Martin (French part),MF
Saint Pierre and Miquelon,PM
Saint Vincent and the Grenadines,VC
Samoa,WS
San Marino,SM
Sao Tome and Principe,ST
Saudi Arabia,SA
Senegal,SN
Serbia,RS
Seychelles,SC
Sierra Leone,SL
Singapore,SG
Sint Maarten (Dutch part),SX
Slovakia,SK
Slovenia,SI
Solomon Islands,SB
Somalia,SO
South Africa,ZA
South Georgia and the South Sandwich Islands,GS
South Sudan,SS
Spain,ES
Sri Lanka,LK
Sudan,SD
Suriname,SR
Svalbard and Jan Mayen,SJ
Swaziland,SZ
Sweden,SE
Switzerland,CH
Syrian Arab Republic,SY
"Taiwan, Province of China",TW
Tajikistan,TJ
"Tanzania, United Republic of",TZ
Thailand,TH
Timor-Leste,TL
Togo,TG
Tokelau,TK
Tonga,TO
Trinidad and Tobago,TT
Tunisia,TN
Turkey,TR
Turkmenistan,TM
Turks and Caicos Islands,TC
Tuvalu,TV
Uganda,UG
Ukraine,UA
United Arab Emirates,AE
United Kingdom,GB
United States,US
United States Minor Outlying Islands,UM
Uruguay,UY
Uzbekistan,UZ
Vanuatu,VU
"Venezuela, Bolivarian Republic of",VE
Viet Nam,VN
"Virgin Islands, British",VG
"Virgin Islands, U.S.",VI
Wallis and Futuna,WF
Western Sahara,EH
Yemen,YE
Zambia,ZM
Zimbabwe,ZW
1 Name Code
2 Afghanistan AF
3 Åland Islands AX
4 Albania AL
5 Algeria DZ
6 American Samoa AS
7 Andorra AD
8 Angola AO
9 Anguilla AI
10 Antarctica AQ
11 Antigua and Barbuda AG
12 Argentina AR
13 Armenia AM
14 Aruba AW
15 Australia AU
16 Austria AT
17 Azerbaijan AZ
18 Bahamas BS
19 Bahrain BH
20 Bangladesh BD
21 Barbados BB
22 Belarus BY
23 Belgium BE
24 Belize BZ
25 Benin BJ
26 Bermuda BM
27 Bhutan BT
28 Bolivia, Plurinational State of BO
29 Bonaire, Sint Eustatius and Saba BQ
30 Bosnia and Herzegovina BA
31 Botswana BW
32 Bouvet Island BV
33 Brazil BR
34 British Indian Ocean Territory IO
35 Brunei Darussalam BN
36 Bulgaria BG
37 Burkina Faso BF
38 Burundi BI
39 Cambodia KH
40 Cameroon CM
41 Canada CA
42 Cape Verde CV
43 Cayman Islands KY
44 Central African Republic CF
45 Chad TD
46 Chile CL
47 China CN
48 Christmas Island CX
49 Cocos (Keeling) Islands CC
50 Colombia CO
51 Comoros KM
52 Congo CG
53 Congo, the Democratic Republic of the CD
54 Cook Islands CK
55 Costa Rica CR
56 Côte d'Ivoire CI
57 Croatia HR
58 Cuba CU
59 Curaçao CW
60 Cyprus CY
61 Czech Republic CZ
62 Denmark DK
63 Djibouti DJ
64 Dominica DM
65 Dominican Republic DO
66 Ecuador EC
67 Egypt EG
68 El Salvador SV
69 Equatorial Guinea GQ
70 Eritrea ER
71 Estonia EE
72 Ethiopia ET
73 Falkland Islands (Malvinas) FK
74 Faroe Islands FO
75 Fiji FJ
76 Finland FI
77 France FR
78 French Guiana GF
79 French Polynesia PF
80 French Southern Territories TF
81 Gabon GA
82 Gambia GM
83 Georgia GE
84 Germany DE
85 Ghana GH
86 Gibraltar GI
87 Greece GR
88 Greenland GL
89 Grenada GD
90 Guadeloupe GP
91 Guam GU
92 Guatemala GT
93 Guernsey GG
94 Guinea GN
95 Guinea-Bissau GW
96 Guyana GY
97 Haiti HT
98 Heard Island and McDonald Islands HM
99 Holy See (Vatican City State) VA
100 Honduras HN
101 Hong Kong HK
102 Hungary HU
103 Iceland IS
104 India IN
105 Indonesia ID
106 Iran, Islamic Republic of IR
107 Iraq IQ
108 Ireland IE
109 Isle of Man IM
110 Israel IL
111 Italy IT
112 Jamaica JM
113 Japan JP
114 Jersey JE
115 Jordan JO
116 Kazakhstan KZ
117 Kenya KE
118 Kiribati KI
119 Korea, Democratic People's Republic of KP
120 Korea, Republic of KR
121 Kuwait KW
122 Kyrgyzstan KG
123 Lao People's Democratic Republic LA
124 Latvia LV
125 Lebanon LB
126 Lesotho LS
127 Liberia LR
128 Libya LY
129 Liechtenstein LI
130 Lithuania LT
131 Luxembourg LU
132 Macao MO
133 Macedonia, the Former Yugoslav Republic of MK
134 Madagascar MG
135 Malawi MW
136 Malaysia MY
137 Maldives MV
138 Mali ML
139 Malta MT
140 Marshall Islands MH
141 Martinique MQ
142 Mauritania MR
143 Mauritius MU
144 Mayotte YT
145 Mexico MX
146 Micronesia, Federated States of FM
147 Moldova, Republic of MD
148 Monaco MC
149 Mongolia MN
150 Montenegro ME
151 Montserrat MS
152 Morocco MA
153 Mozambique MZ
154 Myanmar MM
155 Namibia NA
156 Nauru NR
157 Nepal NP
158 Netherlands NL
159 New Caledonia NC
160 New Zealand NZ
161 Nicaragua NI
162 Niger NE
163 Nigeria NG
164 Niue NU
165 Norfolk Island NF
166 Northern Mariana Islands MP
167 Norway NO
168 Oman OM
169 Pakistan PK
170 Palau PW
171 Palestine, State of PS
172 Panama PA
173 Papua New Guinea PG
174 Paraguay PY
175 Peru PE
176 Philippines PH
177 Pitcairn PN
178 Poland PL
179 Portugal PT
180 Puerto Rico PR
181 Qatar QA
182 Réunion RE
183 Romania RO
184 Russian Federation RU
185 Rwanda RW
186 Saint Barthélemy BL
187 Saint Helena, Ascension and Tristan da Cunha SH
188 Saint Kitts and Nevis KN
189 Saint Lucia LC
190 Saint Martin (French part) MF
191 Saint Pierre and Miquelon PM
192 Saint Vincent and the Grenadines VC
193 Samoa WS
194 San Marino SM
195 Sao Tome and Principe ST
196 Saudi Arabia SA
197 Senegal SN
198 Serbia RS
199 Seychelles SC
200 Sierra Leone SL
201 Singapore SG
202 Sint Maarten (Dutch part) SX
203 Slovakia SK
204 Slovenia SI
205 Solomon Islands SB
206 Somalia SO
207 South Africa ZA
208 South Georgia and the South Sandwich Islands GS
209 South Sudan SS
210 Spain ES
211 Sri Lanka LK
212 Sudan SD
213 Suriname SR
214 Svalbard and Jan Mayen SJ
215 Swaziland SZ
216 Sweden SE
217 Switzerland CH
218 Syrian Arab Republic SY
219 Taiwan, Province of China TW
220 Tajikistan TJ
221 Tanzania, United Republic of TZ
222 Thailand TH
223 Timor-Leste TL
224 Togo TG
225 Tokelau TK
226 Tonga TO
227 Trinidad and Tobago TT
228 Tunisia TN
229 Turkey TR
230 Turkmenistan TM
231 Turks and Caicos Islands TC
232 Tuvalu TV
233 Uganda UG
234 Ukraine UA
235 United Arab Emirates AE
236 United Kingdom GB
237 United States US
238 United States Minor Outlying Islands UM
239 Uruguay UY
240 Uzbekistan UZ
241 Vanuatu VU
242 Venezuela, Bolivarian Republic of VE
243 Viet Nam VN
244 Virgin Islands, British VG
245 Virgin Islands, U.S. VI
246 Wallis and Futuna WF
247 Western Sahara EH
248 Yemen YE
249 Zambia ZM
250 Zimbabwe ZW