Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Created by https://www.toptal.com/developers/gitignore/api/java,intellij+iml
# Edit at https://www.toptal.com/developers/gitignore?templates=java,intellij+iml

### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# Idea folder
.idea/

.fleet/

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# End of https://www.toptal.com/developers/gitignore/api/java,intellij+iml
176 changes: 176 additions & 0 deletions reto1/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import java.util.HashMap;
import java.util.Scanner;

public class Main {
private static final HashMap<Integer, Player> players = new HashMap<>();
private static final Scanner scanner = new Scanner(System.in);

public static void main(String[] args) throws InterruptedException {
initializePlayers();

while (true){
switch (mainMenu()){
case 1 -> {
playerReview();
Thread.sleep(2000);
}
case 2 -> {
playerCompare();
Thread.sleep(2000);
}
case 3 -> {
fastestPlayer();
Thread.sleep(2000);
}
case 4 -> {
topGoalPlayer();
Thread.sleep(2000);
}
case 5 -> {
mostAssistsPlayer();
Thread.sleep(2000);
}
case 6 -> {
highestPassingPlayer();
Thread.sleep(2000);
}
case 7 -> {
mostDefensivePlayer();
Thread.sleep(2000);
}
case 8 -> System.exit(0);
default -> System.out.println("Wrong Option!");
}
}
}

private static void mostDefensivePlayer() {
Player topDefensivePlayer = null;
int defence = -1;

for(Player player: players.values()){
if (player.getDefence() > defence){
topDefensivePlayer = player;
defence = topDefensivePlayer.getDefence();
}
}

System.out.println("The top Defensive Involvements is: "+ topDefensivePlayer.getNAME() + " and his/her attribute value is: "+ topDefensivePlayer.getDefence());
}

private static void highestPassingPlayer() {
Player topPassingAccuracyPlayer = null;
int passingAccuracy = -1;

for(Player player: players.values()){
if (player.getAccuracy() > passingAccuracy){
topPassingAccuracyPlayer = player;
passingAccuracy = topPassingAccuracyPlayer.getAccuracy();
}
}

System.out.println("The top Passing Accuracy is: "+ topPassingAccuracyPlayer.getNAME() + " and his/her attribute value is: "+ topPassingAccuracyPlayer.getAccuracy());
}

private static void mostAssistsPlayer() {
Player topPlayerAssistant = null;
int assists = -1;

for(Player player: players.values()){
if (player.getAssists() > assists){
topPlayerAssistant = player;
assists = topPlayerAssistant.getAssists();
}
}

System.out.println("The top Assistant is: "+ topPlayerAssistant.getNAME() + " and his/her attribute value is: " + topPlayerAssistant.getAssists());
}

private static void topGoalPlayer() {

Player topScorerPlayer = null;
int scorer = -1;

for(Player player: players.values()){
if (player.getGoals() > scorer){
topScorerPlayer = player;
scorer = topScorerPlayer.getGoals();
}
}

System.out.println("The top Scorer is: "+ topScorerPlayer.getNAME() + " and his/her attribute value is: "+ topScorerPlayer.getGoals());

}

private static void fastestPlayer() {
Player playerFastest = null;
int fastest = -1;

for(Player player: players.values()){
if (player.getSpeed() > fastest){
playerFastest = player;
fastest = playerFastest.getSpeed();
}
}

System.out.println("The Fastest player is: "+ playerFastest.getNAME() + " and his/her attribute value is: "+ playerFastest.getSpeed());

}

private static void playerCompare() {
System.out.print("Introduce the first Jersey Number: ");
int jerseyNumber1 = scanner.nextInt();
System.out.print("Introduce the second Jersey Number: ");
int jerseyNumber2 = scanner.nextInt();

Player player1 = players.get(jerseyNumber1);
Player player2 = players.get(jerseyNumber2);

if(player1 != null && player2 != null){
System.out.println("*------------Player Compare------------*");
System.out.println("The Player with the Jersey number: " + jerseyNumber1 + " has the following statistics:");
System.out.println(players.get(jerseyNumber1));
System.out.println("The Player with the Jersey number: " + jerseyNumber2 + " has the following statistics:");
System.out.println(players.get(jerseyNumber2));
}else {
System.out.println("Players not Found. Try again!");
}
}

private static void playerReview() {
System.out.print("Introduce the Jersey Number: ");
int jerseyNumber = scanner.nextInt();

if (players.get(jerseyNumber) != null){
System.out.println("The Player with the Jersey number: " + jerseyNumber + " has the following statistics:");
System.out.println(players.get(jerseyNumber));
} else {
System.out.println("Player not Found. Try again!");
}
}

private static int mainMenu(){

System.out.println("*------------Welcome to the statistic tool, chose your option------------*");
System.out.println("1 - Player Review");
System.out.println("2 - Players Comparation");
System.out.println("3 - Fastest Player");
System.out.println("4 - TopGoal Player");
System.out.println("5 - TopAssistant Player");
System.out.println("6 - TopPassing Player");
System.out.println("7 - TopDefensive Player");
System.out.println("8 - Exit");
System.out.print("Select your option: ");

return scanner.nextInt();
}
private static void initializePlayers(){
players.put(8,new Player("Bruno Fernandes", 5, 6, 9,10,3));
players.put(11,new Player("Rasmus Hojlund",12,8,2,6,2));
players.put(5,new Player("Harry Maguire",1,5,1,7,9));
players.put(17,new Player("Alejandro Garnacho",8,7,8,6,0));
players.put(7,new Player("Mason Mount",2,6,4,8,1));
}


}
74 changes: 74 additions & 0 deletions reto1/src/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
public class Player {

private final String NAME;
private Integer goals;
private Integer speed;
private Integer assists;
private Integer accuracy;
private Integer defence;

public Player(String NAME, Integer goals, Integer speed, Integer assists, Integer accuracy, Integer defence) {
this.NAME = NAME;
this.goals = goals;
this.speed = speed;
this.assists = assists;
this.accuracy = accuracy;
this.defence = defence;
}

public String getNAME() {
return NAME;
}

public Integer getGoals() {
return goals;
}

public void setGoals(Integer goals) {
this.goals = goals;
}

public Integer getSpeed() {
return speed;
}

public void setSpeed(Integer speed) {
this.speed = speed;
}

public Integer getAssists() {
return assists;
}

public void setAssists(Integer assists) {
this.assists = assists;
}

public Integer getAccuracy() {
return accuracy;
}

public void setAccuracy(Integer accuracy) {
this.accuracy = accuracy;
}

public Integer getDefence() {
return defence;
}

public void setDefence(Integer defence) {
this.defence = defence;
}

@Override
public String toString() {
return
"Name = " + NAME +
"\nGoals = " + goals +
"\nSpeed = " + speed +
"\nAssists = " + assists +
"\nAccuracy = " + accuracy +
"\nDefensive Involvements = " + defence
;
}
}
Loading