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
6 changes: 6 additions & 0 deletions L1E1/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
54 changes: 54 additions & 0 deletions L1E1/L1E1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CC6E8B6E-1D5E-4A00-B2B9-0725E65EA4A3}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>L1E1</RootNamespace>
<AssemblyName>L1E1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Player.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
25 changes: 25 additions & 0 deletions L1E1/L1E1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L1E1", "L1E1.csproj", "{CC6E8B6E-1D5E-4A00-B2B9-0725E65EA4A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CC6E8B6E-1D5E-4A00-B2B9-0725E65EA4A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC6E8B6E-1D5E-4A00-B2B9-0725E65EA4A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC6E8B6E-1D5E-4A00-B2B9-0725E65EA4A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC6E8B6E-1D5E-4A00-B2B9-0725E65EA4A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F9D23855-AEAE-41C7-BC45-4B6237A4893A}
EndGlobalSection
EndGlobal
33 changes: 33 additions & 0 deletions L1E1/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace L1E1
{
internal class Player
{

public int number { get; set; }
public string name { get; set; }
public int goals { get; set; }
public int speedPoints { get; set; }
public int assistsPoints { get; set; }
public int passingPoints { get; set; }
public int defensePoints { get; set; }

public Player(string playerName, int playerNumber, int playerGoals, int playerSpeed, int playerAssistsPoints, int playerPassingPoints, int playerDefensePoints)
{
this.name = playerName;
this.number = playerNumber;
this.goals = playerGoals;
this.speedPoints = playerSpeed;
this.assistsPoints = playerAssistsPoints;
this.passingPoints = playerPassingPoints;
this.defensePoints = playerDefensePoints;

}

}
}
270 changes: 270 additions & 0 deletions L1E1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace L1E1
{
//Blindma1den Discord Community - Programming Level 1, Exercise 1

/*
1. Manchester United FC has hired you as a developer. Develop a program that helps the coach identify their fastest player, player with the most goals, assists, passing accuracy, and defensive involvements.
The system should also allow comparison between two players. Use the following player profiles:

Bruno Fernandes: 5 goals, 6 points in speed, 9 points in assists, 10 points in passing accuracy, 3 defensive involvements. Corresponds to jersey number 8.
Rasmus Hojlund: 12 goals, 8 points in speed, 2 points in assists, 6 points in passing accuracy, 2 defensive involvements. Corresponds to jersey number 11.
Harry Maguire: 1 goal, 5 points in speed, 1 point in assists, 7 points in passing accuracy, 9 defensive involvements. Corresponds to jersey number 5.
Alejandro Garnacho: 8 goals, 7 points in speed, 8 points in assists, 6 points in passing accuracy, 0 defensive involvements. Corresponds to jersey number 17.
Mason Mount: 2 goals, 6 points in speed, 4 points in assists, 8 points in passing accuracy, 1 defensive involvement. Corresponds to jersey number 7.

The program functions as follows: The coach accesses the system and encounters a menu with the following options:

Player Review: By entering the player's jersey number, they can access the player's characteristics.
Compare two players: The system prompts for two jersey numbers and displays the data of both players on screen.
Identify the fastest player: Displays the player with the most points in speed.
Identify the top goal scorer: Displays the player with the most points in goals.
Identify the player with the most assists: Displays the player with the most points in assists.
Identify the player with the highest passing accuracy: Displays the player with the most points in passing accuracy.
Identify the player with the most defensive involvements: Displays the player with the most points in defensive involvements.
The system should also allow returning to the main menu.
*/
internal class Program
{
static void Main(string[] args)
{
const int exitOption = 8;

Player pl1 = new Player("Bruno Fernandez", 8, 5, 6, 9, 10, 3);
Player pl2 = new Player("Rasmus Hojlund", 11, 12, 8, 2, 6, 2);
Player pl3 = new Player("Harry Maguire", 5, 1, 5, 1, 7, 9);
Player pl4 = new Player("Alejandro Garnacho", 17, 8, 7, 8, 6, 0);
Player pl5 = new Player("Mason Mount", 7, 2, 6, 4, 8, 1);

Player[] manchesterUnited = { pl1, pl2, pl3, pl4, pl5 };

int menuOption = 0;

while (menuOption != exitOption)
{
Console.Clear();
ShowMainMenu();
int.TryParse(Console.ReadLine(), out menuOption);

switch (menuOption)
{
case 1: //Review 1 Player
PlayerReview(manchesterUnited);
break;
case 2:
ComparePlayers(manchesterUnited);
break;
case 3:
FastestPlayer(manchesterUnited);
break;
case 4:
TopGoalScorer(manchesterUnited);
break;
case 5:
MostAssistsPlayer(manchesterUnited);
break;
case 6:
HighestPassingPlayer(manchesterUnited);
break;
case 7:
MostDefensivePlayer(manchesterUnited);
break;
case 8:
Console.WriteLine("Thanks for using the MUFC Software!");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
Environment.Exit(0);
break;
default:
break;
}

}

}

static void ShowMainMenu()
{
Console.Clear();
Console.WriteLine("--- MANCHESTER UNITED FC SOFTWARE ---");
Console.WriteLine("Welcome to the Manchester United FC Official Software©.\nPlease, choose an option from the menu that is being displayed below:");
Console.WriteLine(
"\n ----------------------------------------------------------------------------------------------------------" +
"\n1. REVIEW A PLAYER: This option allows you to see all the information that a Player has." +
"\n2. COMPARE PLAYERS: This option allows you to compare 2 players" +
"\n3. FASTEST PLAYER: This option allows you to see who is the fastest player." +
"\n4. TOP GOAL SCOARER: This option allows you to see who is the Top Goal Scoarer of the team" +
"\n5. MOST ASSISTS PLAYER: This option allows you to see which Player has the most assists in the team" +
"\n6. HIGHEST PASSING ACCURACY: This option allows you to identify the Player with the highest passing accuracy" +
"\n7. MOST DEFENSIVE PLAYER: This option allows you to see the Player with the most defensive involvements" +
"\n----------------------------------------------------------------------------------------------------------" +
"\nRemember: You can type '8' to exit the Software!");

}
static void PlayerReview(Player[] teamParameter)
{
int jerseyNumber;
int confirmOption = 0;
Console.Clear();
Console.WriteLine("Welcome, this is the Player Review option.\nPlease, enter the player's jersey number to continue");
int.TryParse(Console.ReadLine(), out jerseyNumber);

foreach (var player in teamParameter)
{
if (player.number == jerseyNumber)
{
PlayerInfo(player);
Console.WriteLine("Press a key to continue...");
Console.ReadKey();
}
}
}

static void ComparePlayers(Player[] teamParameter)
{
int firstPlayer, secondPlayer;
Console.Clear();
Console.WriteLine("Please, enter the jersey number of the first player");
int.TryParse(Console.ReadLine(), out firstPlayer);
Console.WriteLine("Please, enter the jersey number of the first player");
int.TryParse(Console.ReadLine(), out secondPlayer);

foreach (var player in teamParameter)
{
if (player.number == firstPlayer)
{
Console.WriteLine("First Player:");
PlayerInfo(player);
}

if (player.number == secondPlayer)
{
Console.WriteLine("Second Player:");
PlayerInfo(player);
}
}

Console.WriteLine("Press any key to continue...");
Console.ReadKey();

}

static void FastestPlayer(Player[] teamParameter)
{
int maxSpeed = 0;
Player fastestPlayer = null;

foreach (var player in teamParameter)
{
if (player.speedPoints > maxSpeed)
{
maxSpeed = player.speedPoints;
fastestPlayer = player;
}
}

Console.WriteLine("Fastest Player: \n");
PlayerInfo(fastestPlayer);
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}

static void TopGoalScorer(Player[] teamParameter)
{
int maxGoals = 0;
Player topGoalerPlayer = null;

foreach (var player in teamParameter)
{
if (player.goals > maxGoals)
{
maxGoals = player.goals;
topGoalerPlayer = player;
}
}
Console.WriteLine("Top Goaler Player: \n");
PlayerInfo(topGoalerPlayer);
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();

}

static void MostAssistsPlayer(Player[] teamParameter)
{
int maxAssists = 0;
Player mostAssistsPlayer = null;

foreach (var player in teamParameter)
{
if (player.assistsPoints > maxAssists)
{
maxAssists = player.assistsPoints;
mostAssistsPlayer = player;
}
}
Console.WriteLine("Most Assists Player: \n");
PlayerInfo(mostAssistsPlayer);
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}

static void HighestPassingPlayer(Player[] teamParameter)
{
int highestNumPassing = 0;
Player highestPassingPlayer = null;

foreach (var player in teamParameter)
{
if (player.passingPoints > highestNumPassing)
{
highestNumPassing = player.passingPoints;
highestPassingPlayer = player;
}
}
Console.WriteLine("Highest Passing Points Player: \n");
PlayerInfo(highestPassingPlayer);
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}

static void MostDefensivePlayer(Player[] teamParameter)
{
int mostDefense = 0;
Player mostDefensivePlayer = null;

foreach (var player in teamParameter)
{
if (player.defensePoints > mostDefense)
{
mostDefense = player.defensePoints;
mostDefensivePlayer = player;
}
}
Console.WriteLine("Most Defensive Player: \n");
PlayerInfo(mostDefensivePlayer);
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}

static void PlayerInfo(Player playerParameter)
{
Console.WriteLine("---------------------------");
Console.WriteLine("--- PLAYER INFORMATION ---");
Console.WriteLine($"Player's Jersey Number: {playerParameter.number}, Name: {playerParameter.name}");
Console.WriteLine("STATISTICS");
Console.WriteLine($"GOALS: {playerParameter.goals}" +
$"\nSPEED: {playerParameter.speedPoints}" +
$"\nASSISTS: {playerParameter.assistsPoints}" +
$"\nPASSING ACC: {playerParameter.passingPoints}" +
$"\nDEFENSE: {playerParameter.defensePoints}");
Console.WriteLine("---------------------------");

}
}
}
Loading