first commit
This commit is contained in:
commit
9c4ddc5654
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>assignment_2</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1675021093357</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?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.r0r5chach</groupId>
|
||||||
|
<artifactId>assignment_2</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-api</artifactId>
|
||||||
|
<version>5.4.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>5.4.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class CompetitorList {
|
||||||
|
private final ArrayList<ValorantPlayer> competitors;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String reportContents;
|
||||||
|
|
||||||
|
|
||||||
|
public CompetitorList(File list) throws IOException {
|
||||||
|
competitors = new ArrayList<>();
|
||||||
|
readCompetitors(list);
|
||||||
|
reportContents = reportTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReportContents() {
|
||||||
|
return reportContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<ValorantPlayer> getCompetitors() {
|
||||||
|
return competitors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readCompetitors(File list) throws FileNotFoundException {
|
||||||
|
Scanner reader = new Scanner(list);
|
||||||
|
while (reader.hasNextLine()) {
|
||||||
|
String[] row = reader.nextLine().split("%");
|
||||||
|
competitors.add(parseRow(row));
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ValorantPlayer parseRow(String[] row) {
|
||||||
|
int playerNumber = Integer.parseInt(row[0]);
|
||||||
|
Name playerName = new Name(row[1]);
|
||||||
|
ValorantRank playerLevel = ValorantRank.valueOf(row[2]);
|
||||||
|
ValorantAgent favoriteAgent = ValorantAgent.valueOf(row[3]);
|
||||||
|
int[] scores = parseScores(row[4]);
|
||||||
|
return new ValorantPlayer(playerNumber, playerName, playerLevel, favoriteAgent, scores);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] parseScores(String row) {
|
||||||
|
String[] scores = row.split(",");
|
||||||
|
int[] parsedScores = new int[scores.length];
|
||||||
|
for (int i = 0; i < scores.length; i++) {
|
||||||
|
parsedScores[i] = Integer.parseInt(scores[i]);
|
||||||
|
}
|
||||||
|
return parsedScores;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateTable() {
|
||||||
|
StringBuilder table = new StringBuilder("Competitor Level Agent Scores Overall");
|
||||||
|
for (ValorantPlayer player: getCompetitors()) {
|
||||||
|
table.append("\n");
|
||||||
|
for (String detail: player.getFullDetails().split("\n")) {
|
||||||
|
String[] detailParts = detail.split(": ");
|
||||||
|
if (detailParts[0].equals("Player Number")) {
|
||||||
|
table.append(detailParts[1]).append(" ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
table.append(detailParts[1]).append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return table.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] generateLevelFreqs() {
|
||||||
|
int[] freqs = {0, 0, 0, 0};
|
||||||
|
for (ValorantPlayer player: getCompetitors()) {
|
||||||
|
switch (player.getPlayerLevel()) {
|
||||||
|
case IRON -> freqs[0] += 1;
|
||||||
|
case BRONZE -> freqs[1] += 1;
|
||||||
|
case SILVER -> freqs[2] += 1;
|
||||||
|
case GOLD -> freqs[3] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return freqs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] generateScoreFreqs() {
|
||||||
|
int[] freqs = {0, 0, 0, 0, 0, 0};
|
||||||
|
for (ValorantPlayer player: getCompetitors()) {
|
||||||
|
for (int score: player.getScores()) {
|
||||||
|
switch (score) {
|
||||||
|
case 0 -> freqs[0] += 1;
|
||||||
|
case 1 -> freqs[1] += 1;
|
||||||
|
case 2 -> freqs[2] += 1;
|
||||||
|
case 3 -> freqs[3] += 1;
|
||||||
|
case 4 -> freqs[4] += 1;
|
||||||
|
case 5 -> freqs[5] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return freqs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double generateAverageScore() {
|
||||||
|
double avg = 0;
|
||||||
|
int totalScores = 0;
|
||||||
|
for (ValorantPlayer player: getCompetitors()) {
|
||||||
|
for (int score: player.getScores()) {
|
||||||
|
totalScores += 1;
|
||||||
|
avg += score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
avg /= totalScores;
|
||||||
|
return avg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getHighScore() {
|
||||||
|
double hS = 0;
|
||||||
|
for (ValorantPlayer player: getCompetitors()) {
|
||||||
|
if (player.getOverallScore() > hS) {
|
||||||
|
hS = player.getOverallScore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File createReportFile() throws IOException {
|
||||||
|
boolean exists;
|
||||||
|
int count = 0;
|
||||||
|
Path path;
|
||||||
|
FileWriter report = null;
|
||||||
|
|
||||||
|
do {
|
||||||
|
path = Path.of("src/main/resources/report"+count+ ".txt");
|
||||||
|
exists = Files.exists(path);
|
||||||
|
|
||||||
|
if(exists) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Files.createFile(path);
|
||||||
|
report = new FileWriter(String.valueOf(path));
|
||||||
|
}
|
||||||
|
}while (exists);
|
||||||
|
|
||||||
|
generateReportContents();
|
||||||
|
report.append(reportContents);
|
||||||
|
report.close();
|
||||||
|
reportContents = reportTemplate();
|
||||||
|
return new File(path.toUri());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createErrorLog(Exception e, String path) {
|
||||||
|
try {
|
||||||
|
FileWriter log = new FileWriter(path);
|
||||||
|
log.append(String.valueOf(e));
|
||||||
|
log.close();
|
||||||
|
return Files.readString(Path.of(path));
|
||||||
|
}
|
||||||
|
catch (IOException ie) {
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceVar(String target, String replacement) {
|
||||||
|
reportContents = reportContents.replace(target, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String reportTemplate() throws IOException {
|
||||||
|
return Files.readString(Path.of("src/main/resources/report.template"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateReportContents() {
|
||||||
|
replaceVar("%TABLE%", generateTable());
|
||||||
|
replaceVar( "%HIGH-SCORE%", String.valueOf(getHighScore()));
|
||||||
|
replaceVar( "%AVG-SCORE%", String.valueOf(generateAverageScore()));
|
||||||
|
|
||||||
|
int[] freqs = generateLevelFreqs();
|
||||||
|
for (int i = 0; i < freqs.length; i++) {
|
||||||
|
replaceVar( "%LEVEL"+i+"%", ValorantRank.values()[i].getRank());
|
||||||
|
replaceVar( "%VALUE"+i+"%", String.valueOf(freqs[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
freqs = generateScoreFreqs();
|
||||||
|
for (int i = 0; i < freqs.length; i++) {
|
||||||
|
replaceVar( "%SCORE"+i+"%", String.valueOf(freqs[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Manager manager = new Manager();
|
||||||
|
try {
|
||||||
|
System.out.println(Files.readString(manager.getReport().toPath()));
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("reading error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.r0r5chach.CompetitorList.createErrorLog;
|
||||||
|
|
||||||
|
public class Manager {
|
||||||
|
|
||||||
|
private CompetitorList competitors;
|
||||||
|
|
||||||
|
|
||||||
|
public Manager() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitorList getCompetitors() {
|
||||||
|
return competitors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public File getReport() {
|
||||||
|
File report;
|
||||||
|
try {
|
||||||
|
report = competitors.createReportFile();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
report = new File(createErrorLog(e, "src/main/resource/log.txt"));
|
||||||
|
}
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
File sourceFile = new File("src/main/resources/test.txt");
|
||||||
|
try {
|
||||||
|
competitors = new CompetitorList(sourceFile);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
createErrorLog(e, "src/main/resources/log.txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that defines a name and it's parts
|
||||||
|
* @author John.Kanyaru@northampton.ac.uk
|
||||||
|
*/
|
||||||
|
public class Name {
|
||||||
|
/**
|
||||||
|
* The first name of the stored name
|
||||||
|
*/
|
||||||
|
private String firstName;
|
||||||
|
/**
|
||||||
|
* The middle name of the stored name
|
||||||
|
*/
|
||||||
|
private String middleName;
|
||||||
|
/**
|
||||||
|
* The last name of the stored name
|
||||||
|
*/
|
||||||
|
private String lastName;
|
||||||
|
/**
|
||||||
|
* Construct a name that does not contain a middle name
|
||||||
|
* @param fName the first name of the name to be stored
|
||||||
|
* @param lName the last name of the name to be stored
|
||||||
|
*/
|
||||||
|
public Name(String fName, String lName) {
|
||||||
|
firstName = fName;
|
||||||
|
middleName = "";
|
||||||
|
lastName = lName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Construct a name that does have a middle name
|
||||||
|
* @param fName the first name of the name to be stored
|
||||||
|
* @param mName the middle name of the name to be stored
|
||||||
|
* @param lName the last name of the name to be stored
|
||||||
|
*/
|
||||||
|
public Name(String fName, String mName, String lName) {
|
||||||
|
firstName = fName;
|
||||||
|
middleName = mName;
|
||||||
|
lastName = lName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Construct a name from a single string
|
||||||
|
* @param fullName the first, middle, and last names of the name to be stored separated by whitespace
|
||||||
|
*/
|
||||||
|
public Name (String fullName) {
|
||||||
|
int spacePos1 = fullName.indexOf(' ');
|
||||||
|
firstName = fullName.substring(0, spacePos1);
|
||||||
|
int spacePos2 = fullName.lastIndexOf(' ');
|
||||||
|
if (spacePos1 == spacePos2)
|
||||||
|
middleName = "";
|
||||||
|
else
|
||||||
|
middleName = fullName.substring(spacePos1+1, spacePos2);
|
||||||
|
lastName = fullName.substring(spacePos2 + 1);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the first name of the stored name
|
||||||
|
* @return the first name of the stored name
|
||||||
|
*/
|
||||||
|
public String getFirstName() {return firstName; }
|
||||||
|
/**
|
||||||
|
* Get the middle name of the stored name
|
||||||
|
* @return the middle name of the stored name
|
||||||
|
*/
|
||||||
|
public String getMiddleName() { return middleName; }
|
||||||
|
/**
|
||||||
|
* Get the last name of the stored name
|
||||||
|
* @return the last name of the stored name
|
||||||
|
*/
|
||||||
|
public String getLastName() {return lastName; }
|
||||||
|
/**
|
||||||
|
* Set the stored name's first name to that of the parameter
|
||||||
|
* @param fn the new first name
|
||||||
|
*/
|
||||||
|
public void setFirstName(String fn) {
|
||||||
|
firstName = fn;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the stored name's middle name to that of the parameter
|
||||||
|
* @param mn the new middle name
|
||||||
|
*/
|
||||||
|
public void setMiddleName(String mn) {
|
||||||
|
middleName = mn;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the stored name's last name to that of the parameter
|
||||||
|
* @param ln the new last name
|
||||||
|
*/
|
||||||
|
public void setLastName(String ln) {
|
||||||
|
lastName = ln;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the first and last name of the stored name
|
||||||
|
* @return a formatted string containing both the first and last names
|
||||||
|
*/
|
||||||
|
public String getFirstAndLastName() {
|
||||||
|
return firstName + " " + lastName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the last and first names of the stored name
|
||||||
|
* @return a formatted string contains both the first and last names in reverse order
|
||||||
|
*/
|
||||||
|
public String getLastCommaFirst() {
|
||||||
|
return lastName + ", "+ firstName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the full stored name
|
||||||
|
* @return a string containing the first, middle, and last names
|
||||||
|
*/
|
||||||
|
public String getFullName() {
|
||||||
|
String result = firstName + " ";
|
||||||
|
if (!middleName.equals("")) {
|
||||||
|
result += middleName + " ";
|
||||||
|
}
|
||||||
|
result += lastName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the initials of the stored name
|
||||||
|
* @return a string containing the initials
|
||||||
|
* @author r0r5chach
|
||||||
|
*/
|
||||||
|
public String getInitials() {
|
||||||
|
String result = firstName.substring(0,1);
|
||||||
|
if (!middleName.equals("")) {
|
||||||
|
result += middleName.substring(0,1);
|
||||||
|
}
|
||||||
|
result += lastName.substring(0,1);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All Characters a ValorantPlayer can play
|
||||||
|
* @author r0r5chach
|
||||||
|
*/
|
||||||
|
public enum ValorantAgent {
|
||||||
|
BRIMSTONE,
|
||||||
|
VIPER,
|
||||||
|
OMEN,
|
||||||
|
KILLJOY,
|
||||||
|
CYPHER,
|
||||||
|
SOVA,
|
||||||
|
SAGE,
|
||||||
|
PHOENIX,
|
||||||
|
JETT,
|
||||||
|
REYNA,
|
||||||
|
RAZE,
|
||||||
|
BREACH,
|
||||||
|
SKYE,
|
||||||
|
YORU,
|
||||||
|
ASTRA,
|
||||||
|
KAYO,
|
||||||
|
CHAMBER,
|
||||||
|
NEON,
|
||||||
|
FADE,
|
||||||
|
HARBOR;
|
||||||
|
/**
|
||||||
|
* Get the name of the character
|
||||||
|
* @return a formatted string containing the character name
|
||||||
|
*/
|
||||||
|
public String getAgent() {
|
||||||
|
return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalizes the first letter and makes sure the other letters are lowercase
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,155 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that defines the various attributes and methods associated with a Valorant Player
|
||||||
|
* @author r0r5chach
|
||||||
|
*/
|
||||||
|
public class ValorantPlayer {
|
||||||
|
/**
|
||||||
|
* The format to use when converting decimal numbers to strings
|
||||||
|
*/
|
||||||
|
private static final DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
/**
|
||||||
|
* The number of the player in the competition
|
||||||
|
*/
|
||||||
|
private int playerNumber;
|
||||||
|
/**
|
||||||
|
* The name of the player in the competition
|
||||||
|
*/
|
||||||
|
private Name playerName;
|
||||||
|
/**
|
||||||
|
* The level the player plays at in the competition
|
||||||
|
* These are derived from the first 4 ranks of the normal game
|
||||||
|
*/
|
||||||
|
private ValorantRank playerLevel;
|
||||||
|
/**
|
||||||
|
* The character the player plays the most
|
||||||
|
*/
|
||||||
|
private ValorantAgent favouriteAgent;
|
||||||
|
/**
|
||||||
|
* The scores the player has received
|
||||||
|
*/
|
||||||
|
private int[] scores;
|
||||||
|
/**
|
||||||
|
* Constructs an object with attributes matching the parameters passed
|
||||||
|
* @param playerNumber the number of the player
|
||||||
|
* @param playerName the name of the player
|
||||||
|
* @param playerLevel the level of the player
|
||||||
|
* @param favouriteAgent the character the player plays most
|
||||||
|
*/
|
||||||
|
public ValorantPlayer(int playerNumber, Name playerName, ValorantRank playerLevel, ValorantAgent favouriteAgent, int[] scores) {
|
||||||
|
this.playerNumber = playerNumber;
|
||||||
|
this.playerName = playerName;
|
||||||
|
this.playerLevel = playerLevel;
|
||||||
|
this.favouriteAgent = favouriteAgent;
|
||||||
|
this.scores = scores;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the player's number to that of the parameter
|
||||||
|
* @param playerNumber the new number of the player
|
||||||
|
*/
|
||||||
|
public void setPlayerNumber(int playerNumber) {
|
||||||
|
this.playerNumber = playerNumber;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the player's name to that of the parameter
|
||||||
|
* @param playerName the new name of the player
|
||||||
|
*/
|
||||||
|
public void setPlayerName(Name playerName) {
|
||||||
|
this.playerName = playerName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the player's level to that of the parameter
|
||||||
|
* @param playerLevel the new level of the player
|
||||||
|
*/
|
||||||
|
public void setPlayerLevel(ValorantRank playerLevel) {
|
||||||
|
this.playerLevel = playerLevel;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the player's most played character to that of the parameter
|
||||||
|
* @param favouriteAgent the new most played character of the player
|
||||||
|
*/
|
||||||
|
public void setFavouriteAgent(ValorantAgent favouriteAgent) {
|
||||||
|
this.favouriteAgent = favouriteAgent;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set the player's scores
|
||||||
|
* @param scores the new scores for the player
|
||||||
|
*/
|
||||||
|
public void setScores(int[] scores) {
|
||||||
|
this.scores = scores;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the player's number
|
||||||
|
* @return the player's number
|
||||||
|
*/
|
||||||
|
public int getPlayerNumber() {
|
||||||
|
return this.playerNumber;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the player's name
|
||||||
|
* @return the player's name
|
||||||
|
*/
|
||||||
|
public Name getPlayerName() {
|
||||||
|
return this.playerName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the player's level
|
||||||
|
* @return the player's level
|
||||||
|
*/
|
||||||
|
public ValorantRank getPlayerLevel() {
|
||||||
|
return this.playerLevel;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the player's most played character
|
||||||
|
* @return the player's most played character
|
||||||
|
*/
|
||||||
|
public ValorantAgent getFavouriteAgent() {
|
||||||
|
return this.favouriteAgent;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the player's scores
|
||||||
|
* @return an array containing the scores
|
||||||
|
*/
|
||||||
|
public int[] getScores() {
|
||||||
|
return this.scores;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Calculates and then returns the overall score of the player.
|
||||||
|
* The score is calculated by taking the natural log of each score and then dividing the sum by 1.93
|
||||||
|
* @return an aggregate of the individual scores the player has achieved
|
||||||
|
*/
|
||||||
|
public double getOverallScore() {
|
||||||
|
double output = 0;
|
||||||
|
for (int score: getScores()) {
|
||||||
|
output += Math.log(score); //get the sum of the natural log of the scores
|
||||||
|
}
|
||||||
|
output /= 1.93; //divide the sum by 1.93
|
||||||
|
if (output == Double.NEGATIVE_INFINITY) {
|
||||||
|
output = 0;
|
||||||
|
}
|
||||||
|
return Double.parseDouble(df.format(output)); //df.format() allows the scores to be formatted to 2 decimal places
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get all the attributes of the player
|
||||||
|
* @return all attributes of the player in a formatted string
|
||||||
|
*/
|
||||||
|
public String getFullDetails() {
|
||||||
|
return "Player Number: " + getPlayerNumber() +
|
||||||
|
"\nName: " + getPlayerName().getFullName() +
|
||||||
|
"\nPlayer Level: " + getPlayerLevel().getRank() +
|
||||||
|
"\nFavourite Agent: " + getFavouriteAgent().getAgent() +
|
||||||
|
"\nScores: " + Arrays.toString(getScores()).replace("[","").replace("]", "") + //replace() allows the array to not be surrounded by brackets
|
||||||
|
"\nOverall Score: " + getOverallScore();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the important attributes of the player
|
||||||
|
* @return a formatted string containing the playerNumber, playerName, and overall score
|
||||||
|
*/
|
||||||
|
public String getShortDetails() {
|
||||||
|
return "CN " + getPlayerNumber() + " (" + getPlayerName().getInitials() + ") has overall score " + getOverallScore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.r0r5chach;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All levels a ValorantPlayer can be
|
||||||
|
* @author r0r5chach
|
||||||
|
*/
|
||||||
|
public enum ValorantRank {
|
||||||
|
/**
|
||||||
|
* First Level
|
||||||
|
*/
|
||||||
|
IRON,
|
||||||
|
/**
|
||||||
|
* Second Level
|
||||||
|
*/
|
||||||
|
BRONZE,
|
||||||
|
/**
|
||||||
|
* Third Level
|
||||||
|
*/
|
||||||
|
SILVER,
|
||||||
|
/**
|
||||||
|
* Four Level
|
||||||
|
*/
|
||||||
|
GOLD;
|
||||||
|
/**
|
||||||
|
* Get the name of a level
|
||||||
|
* @return a formatted string containing the level name
|
||||||
|
*/
|
||||||
|
public String getRank() {
|
||||||
|
return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); //Capitalises the first letter and makes sure the other letters are lowercase
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,12 @@
|
||||||
|
%TABLE%
|
||||||
|
|
||||||
|
|
||||||
|
Statistics
|
||||||
|
The Highest Overall Score: %HIGH-SCORE%
|
||||||
|
Average Score: %AVG-SCORE%
|
||||||
|
Level Distribution:
|
||||||
|
%LEVEL0% %LEVEL1% %LEVEL2% %LEVEL3%
|
||||||
|
%VALUE0% %VALUE1% %VALUE2% %VALUE3%
|
||||||
|
Score Distribution:
|
||||||
|
0 1 2 3 4 5
|
||||||
|
%SCORE0% %SCORE1% %SCORE2% %SCORE3% %SCORE4% %SCORE5%
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
101%Caitlin Emily Head%BRONZE%BREACH%0,1,4,2,1,1
|
||||||
|
102%Joshua Luke Perry%IRON%SOVA%5,5,5,5,5,5
|
||||||
|
103%Bradley Gordon-Taylor%SILVER%VIPER%3,1,3,2,4,1
|
||||||
|
104%Nathan Perry%GOLD%BRIMSTONE%0,0,0,0,0,0
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.CompetitorList;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class CompetitorListTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTest() {
|
||||||
|
try {
|
||||||
|
CompetitorList cL = new CompetitorList(new File("src/main/resources/test.txt"));
|
||||||
|
assertEquals(Files.readString(Path.of("src/main/resources/report.template")), cL.getReportContents());
|
||||||
|
assertEquals(102,cL.getCompetitors().get(1).getPlayerNumber());
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("File doesn't exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestCreateReportFile() {
|
||||||
|
try {
|
||||||
|
CompetitorList cL = new CompetitorList(new File("src/main/resources/test.txt"));
|
||||||
|
assertEquals(Files.readString(Path.of("src/test/java/reportTest.txt")), Files.readString(cL.createReportFile().toPath()));
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("File doesn't exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestCreateErrorLog() {
|
||||||
|
assertEquals("java.io.IOException", CompetitorList.createErrorLog(new IOException(), "src/main/resources/log.txt"));
|
||||||
|
assertEquals("Error", CompetitorList.createErrorLog(new IOException(), "src/main/java"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGenerateTable() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGetHighScore() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGenerateAverageScore() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGenerateLevelFreqs() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGenerateScoreFreqs() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestReplaceVar() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestReportTemplate() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGenerateReportContents() {
|
||||||
|
//Already tested in competitorListTestCreateReportFile
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestParseScores() {
|
||||||
|
//Already tested in competitorListTest
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestParseRow() {
|
||||||
|
//Already tested in competitorListTest
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestReadCompetitors() {
|
||||||
|
//Already tested in competitorListTest
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGetReportContents() {
|
||||||
|
//Already tested in competitorListTest
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void competitorListTestGetCompetitors() {
|
||||||
|
//Already tested in competitorListTest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.Main;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class MainTest {
|
||||||
|
@Test
|
||||||
|
public void mainTest() {
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
ByteArrayOutputStream expected = new ByteArrayOutputStream();
|
||||||
|
System.setOut(new PrintStream(expected));
|
||||||
|
try {
|
||||||
|
System.out.println(Files.readString(Path.of("src/test/java/reportTest.txt")));
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("File doesn't exist");
|
||||||
|
}
|
||||||
|
System.setOut(new PrintStream(output));
|
||||||
|
Main.main(new String[0]);
|
||||||
|
assertEquals(expected.toString(), output.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.Manager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class ManagerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void managerTest() {
|
||||||
|
Manager m = new Manager();
|
||||||
|
assertEquals("Joshua Luke Perry", m.getCompetitors().getCompetitors().get(1).getPlayerName().getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void managerTestGetReport() {
|
||||||
|
try {
|
||||||
|
Manager m = new Manager();
|
||||||
|
assertEquals(Files.readString(Path.of("src/test/java/reportTest.txt")), Files.readString(m.getReport().toPath()));
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("File does not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void managerTestGetCompetitors() {
|
||||||
|
//Already tested in managerTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void managerTestInit() {
|
||||||
|
//Already tested in managerTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.Name;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class NameTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestFNameLName() {
|
||||||
|
Name n = new Name("Joshua", "Perry");
|
||||||
|
assertEquals("Joshua", n.getFirstName());
|
||||||
|
assertEquals("", n.getMiddleName());
|
||||||
|
assertEquals("Perry", n.getLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestFNameMNameLName() {
|
||||||
|
Name n = new Name("Joshua", "Luke", "Perry");
|
||||||
|
assertEquals("Joshua", n.getFirstName());
|
||||||
|
assertEquals("Luke", n.getMiddleName());
|
||||||
|
assertEquals("Perry", n.getLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestFullName() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
assertEquals("Joshua", n.getFirstName());
|
||||||
|
assertEquals("Luke", n.getMiddleName());
|
||||||
|
assertEquals("Perry", n.getLastName());
|
||||||
|
|
||||||
|
n = new Name("Joshua Perry");
|
||||||
|
assertEquals("Joshua", n.getFirstName());
|
||||||
|
assertEquals("", n.getMiddleName());
|
||||||
|
assertEquals("Perry", n.getLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestSetFirstName() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
|
||||||
|
n.setFirstName("Bradley");
|
||||||
|
assertEquals("Bradley", n.getFirstName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestSetLastName() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
|
||||||
|
n.setLastName("Gordon-Taylor");
|
||||||
|
assertEquals("Gordon-Taylor", n.getLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetFirstAndLastName() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
assertEquals("Joshua Perry", n.getFirstAndLastName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetLastCommaFirst() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
assertEquals("Perry, Joshua", n.getLastCommaFirst());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetFullName() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
assertEquals("Joshua Luke Perry", n.getFullName());
|
||||||
|
n.setMiddleName("");
|
||||||
|
assertEquals("Joshua Perry", n.getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetInitials() {
|
||||||
|
Name n = new Name("Joshua Luke Perry");
|
||||||
|
assertEquals("JLP", n.getInitials());
|
||||||
|
n.setMiddleName("");
|
||||||
|
assertEquals("JP", n.getInitials());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetFirstName() {
|
||||||
|
//Already tested in nameTestFNameLName()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetMiddleName() {
|
||||||
|
//Already tested in nameTestFNameMNameLName()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestGetLastName() {
|
||||||
|
//Already tested in nameTestFullName()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nameTestSetMiddleName() {
|
||||||
|
//Already tested in nameTestGetFullName()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.ValorantAgent;
|
||||||
|
|
||||||
|
public class ValorantAgentTest {
|
||||||
|
@Test
|
||||||
|
public void valorantAgentTestGetAgent() {
|
||||||
|
ValorantAgent vA = ValorantAgent.HARBOR;
|
||||||
|
assertEquals("Harbor", vA.getAgent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.Name;
|
||||||
|
import org.r0r5chach.ValorantAgent;
|
||||||
|
import org.r0r5chach.ValorantPlayer;
|
||||||
|
import org.r0r5chach.ValorantRank;
|
||||||
|
public class ValorantPlayerTest {
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTest() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
assertEquals(2, vP.getPlayerNumber());
|
||||||
|
assertEquals("Joshua Luke Perry", vP.getPlayerName().getFullName());
|
||||||
|
assertEquals("Gold", vP.getPlayerLevel().getRank());
|
||||||
|
assertEquals("Fade", vP.getFavouriteAgent().getAgent());
|
||||||
|
assertEquals(5, vP.getOverallScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestSetPlayerNumber() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
vP.setPlayerNumber(5);
|
||||||
|
assertEquals(5, vP.getPlayerNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestSetPlayerName() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
vP.setPlayerName(new Name("Bradley Gordon-Taylor"));
|
||||||
|
assertEquals("Bradley Gordon-Taylor", vP.getPlayerName().getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestSetPlayerLevel() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
vP.setPlayerLevel(ValorantRank.BRONZE);
|
||||||
|
assertEquals("Bronze", vP.getPlayerLevel().getRank());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestSetFavouriteAgent() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
vP.setFavouriteAgent(ValorantAgent.VIPER);
|
||||||
|
assertEquals("Viper", vP.getFavouriteAgent().getAgent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestSetScores() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
vP.setScores(new int[]{0, 0, 0, 0, 0, 0});
|
||||||
|
assertEquals(0, vP.getOverallScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetOverallScore() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
assertEquals(5, vP.getOverallScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetFullDetails() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
assertEquals("""
|
||||||
|
Player Number: 2
|
||||||
|
Name: Joshua Luke Perry
|
||||||
|
Player Level: Gold
|
||||||
|
Favourite Agent: Fade
|
||||||
|
Scores: 5, 5, 5, 5, 5, 5
|
||||||
|
Overall Score: 5.0""", vP.getFullDetails());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetShortDetails() {
|
||||||
|
int[] scores = {5,5,5,5,5,5};
|
||||||
|
ValorantPlayer vP = new ValorantPlayer(2,new Name("Joshua Luke Perry"), ValorantRank.GOLD, ValorantAgent.FADE, scores);
|
||||||
|
|
||||||
|
assertEquals("CN 2 (JLP) has overall score 5.0", vP.getShortDetails());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetPlayerNumber() {
|
||||||
|
//Already tested in valorantPlayerTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetPlayerName() {
|
||||||
|
//Already tested in valorantPlayerTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetPlayerLevel() {
|
||||||
|
//Already tested in valorantPlayerTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void valorantPlayerTestGetFavouriteAgent() {
|
||||||
|
//Already tested in valorantPlayerTest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.r0r5chach.ValorantRank;
|
||||||
|
|
||||||
|
|
||||||
|
public class ValorantRankTest {
|
||||||
|
@Test
|
||||||
|
public void valorantRankTestGetRank() {
|
||||||
|
ValorantRank vR = ValorantRank.IRON;
|
||||||
|
assertEquals("Iron", vR.getRank());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
Competitor Level Agent Scores Overall
|
||||||
|
101 Caitlin Emily Head Bronze Breach 0, 1, 4, 2, 1, 1 0.0
|
||||||
|
102 Joshua Luke Perry Iron Sova 5, 5, 5, 5, 5, 5 5.0
|
||||||
|
103 Bradley Gordon-Taylor Silver Viper 3, 1, 3, 2, 4, 1 2.22
|
||||||
|
104 Nathan Perry Gold Brimstone 0, 0, 0, 0, 0, 0 0.0
|
||||||
|
|
||||||
|
|
||||||
|
Statistics
|
||||||
|
The Highest Overall Score: 5.0
|
||||||
|
Average Score: 2.2083333333333335
|
||||||
|
Level Distribution:
|
||||||
|
Iron Bronze Silver Gold
|
||||||
|
1 1 1 1
|
||||||
|
Score Distribution:
|
||||||
|
0 1 2 3 4 5
|
||||||
|
7 5 2 2 2 6
|
||||||
Loading…
Reference in New Issue