delete or comment all write in class + test of test (j'y arrive pas, je vous laisse essayer)

test_old_branch
Jérémy Mouyon 1 year ago
parent 86b2c5f624
commit 8c609e7ad0

@ -5,9 +5,11 @@ VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qwirkle", "Qwirkle\Qwirkle.csproj", "{DCE2FAE9-9A3A-452E-AFB1-BE3DC5E62BDF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qwirkle", "Qwirkle\Qwirkle.csproj", "{DCE2FAE9-9A3A-452E-AFB1-BE3DC5E62BDF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QwirkleClassLibrary", "QwirkleClassLibrary\QwirkleClassLibrary.csproj", "{75739BB2-4DF5-4282-A7AF-0092E69DBDEC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QwirkleClassLibrary", "QwirkleClassLibrary\QwirkleClassLibrary.csproj", "{75739BB2-4DF5-4282-A7AF-0092E69DBDEC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QwirkleConsoleApp", "QwirkleConsoleApp\QwirkleConsoleApp.csproj", "{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QwirkleConsoleApp", "QwirkleConsoleApp\QwirkleConsoleApp.csproj", "{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestBase", "TestBase\TestBase.csproj", "{34BF84AE-E69C-497E-AF88-390E70C4D568}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -29,6 +31,10 @@ Global
{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Release|Any CPU.ActiveCfg = Release|Any CPU {E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Release|Any CPU.Build.0 = Release|Any CPU {E981D8B4-8768-4055-91DB-0DD3E5FDE29B}.Release|Any CPU.Build.0 = Release|Any CPU
{34BF84AE-E69C-497E-AF88-390E70C4D568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34BF84AE-E69C-497E-AF88-390E70C4D568}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34BF84AE-E69C-497E-AF88-390E70C4D568}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34BF84AE-E69C-497E-AF88-390E70C4D568}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -12,7 +12,7 @@ namespace QwirkleClassLibrary
public Board() public Board()
{ {
Console.WriteLine("BOARD created !"); //Console.WriteLine("BOARD created !");
Cells = new List<Cell>(); Cells = new List<Cell>();
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
@ -37,13 +37,13 @@ namespace QwirkleClassLibrary
} }
else else
{ {
Console.WriteLine("Please enter new coordinates for the cell where you want to place your tile."); //Console.WriteLine("Please enter new coordinates for the cell where you want to place your tile.");
return false; return false;
} }
} }
} }
Console.WriteLine("The cell you're searching for doesn't exist. PLease enter new coordinates for the cell where you want to place your tile."); //Console.WriteLine("The cell you're searching for doesn't exist. PLease enter new coordinates for the cell where you want to place your tile.");
return false; return false;
} }
} }

@ -13,7 +13,7 @@ public class Cell
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
Console.WriteLine("Cell (" + x + ", " + y + ") created"); //Console.WriteLine("Cell (" + x + ", " + y + ") created");
} }
public int GetX public int GetX
@ -41,12 +41,12 @@ public class Cell
if(tile == null) if(tile == null)
{ {
tile = addedTile; tile = addedTile;
Console.WriteLine("The tile of shape " + addedTile.GetShape + " and color " + addedTile.GetColor + " has correctly been added to the cell of coordinates x = " + this.x + ", y = " + this.y); //Console.WriteLine("The tile of shape " + addedTile.GetShape + " and color " + addedTile.GetColor + " has correctly been added to the cell of coordinates x = " + this.x + ", y = " + this.y);
return true; return true;
} }
else else
{ {
Console.WriteLine("There already is a tile in this cell !!"); //Console.WriteLine("There already is a tile in this cell !!");
return false; return false;
} }
} }

@ -42,7 +42,7 @@ namespace QwirkleClassLibrary
get { return bag.TilesInBag(); } get { return bag.TilesInBag(); }
} }
public void ShowTileOfPlayer(int posplayer) public string ShowTileOfPlayer(int posplayer)
{ {
List<Tile> tiles = players[posplayer].Tiles; List<Tile> tiles = players[posplayer].Tiles;
@ -52,7 +52,7 @@ namespace QwirkleClassLibrary
{ {
r = (r + " " + tile.NameColorTile()); r = (r + " " + tile.NameColorTile());
} }
Console.WriteLine(r); return r;
} }
@ -63,7 +63,7 @@ namespace QwirkleClassLibrary
players[old].IsPlaying = false; players[old].IsPlaying = false;
} }
players[neew].IsPlaying = true; players[neew].IsPlaying = true;
Console.WriteLine(players[neew].GetNameTag + " you have main now !");
} }
@ -80,7 +80,7 @@ namespace QwirkleClassLibrary
} }
} }
public void NextPlayer() public string NextPlayer()
{ {
int posPlayerPlay = PositionPlayerPlay(); int posPlayerPlay = PositionPlayerPlay();
@ -92,6 +92,8 @@ namespace QwirkleClassLibrary
} }
SetNextPlayer(posPlayerPlay, posPlayerNextPlay); SetNextPlayer(posPlayerPlay, posPlayerNextPlay);
return (players[posPlayerNextPlay].GetNameTag);
} }
} }

@ -11,24 +11,12 @@ namespace QwirkleClassLibrary
private string nameTag; private string nameTag;
private List<Tile> tiles; private List<Tile> tiles;
private bool isPlaying = false; private bool isPlaying = false;
private Score s; // Les gars, on nous a demandé de ne pas ça, réfléchissez
public Player(string name) public Player(string name)
{ {
nameTag = name; nameTag = name;
tiles = new List<Tile>(); tiles = new List<Tile>();
s = new Score(this);
Console.WriteLine("Player created. Name : " + nameTag + "\n");
} }
public Player() // À enlever c'est pas logique
{
nameTag = "Unknow";
tiles = new List<Tile>();
s = new Score(this);
Console.WriteLine("Player created. Name : " + nameTag + "\n");
}
public string GetNameTag public string GetNameTag
{ {
get { return nameTag; } get { return nameTag; }
@ -37,15 +25,15 @@ namespace QwirkleClassLibrary
public bool IsPlaying public bool IsPlaying
{ {
get { return isPlaying; } get { return isPlaying; }
set { isPlaying = value; } // pour vulgariser, le C# prends la value qui sert d'égalité !! set { isPlaying = value; }
} }
public void AddTilePlayer(Tile tile) public void AddTilePlayer(Tile tile)
{ {
tiles.Add(tile); tiles.Add(tile);
} }
public void RemoveTilePlayer(Tile tile) public bool RemoveTilePlayer(Tile tile)
{ {
tiles.Remove(tile); return tiles.Remove(tile);
} }
public List<Tile> Tiles // Rajouter un "get" là public List<Tile> Tiles // Rajouter un "get" là

@ -15,7 +15,7 @@ namespace QwirkleClassLibrary
{ {
shape = sh; shape = sh;
color = co; color = co;
Console.WriteLine("A tile of shape " + shape + " and color " + color + " has been created."); //Console.WriteLine("A tile of shape " + shape + " and color " + color + " has been created.");
} }
public string NameColorTile() public string NameColorTile()

@ -8,8 +8,8 @@ namespace QwirkleClassLibrary
{ {
public class TileBag public class TileBag
{ {
private int nbtiles; public ReadOnlyMemory<Tile> Tiles { get ; private set; }
private List<Tile> tiles; private List<Tile> tiles = new List<Tile>();
public TileBag(int nbSet) public TileBag(int nbSet)
{ {
@ -29,7 +29,6 @@ namespace QwirkleClassLibrary
} }
} }
public void RemoveTileInBag(Tile tile) public void RemoveTileInBag(Tile tile)
@ -39,7 +38,6 @@ namespace QwirkleClassLibrary
if (tiles[i] == tile) if (tiles[i] == tile)
{ {
tiles.RemoveAt(i); tiles.RemoveAt(i);
nbtiles--;
} }
} }
} }

@ -61,10 +61,15 @@ static void testJeremy()
Game game = InitializerGame(); Game game = InitializerGame();
Write("\n -------------------------------------------------------- \n"); Write("\n -------------------------------------------------------- \n");
game.NextPlayer(); String TagPlayerPlay;
game.NextPlayer();
game.NextPlayer(); TagPlayerPlay = game.NextPlayer();
game.NextPlayer();
Write(TagPlayerPlay + " you have main now !");
TagPlayerPlay = game.NextPlayer();
Write(TagPlayerPlay + " you have main now !");
game.TilsBagPlayer(); game.TilsBagPlayer();
@ -72,6 +77,7 @@ static void testJeremy()
{ {
game.ShowTileOfPlayer(i); game.ShowTileOfPlayer(i);
} }
} }

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\QwirkleClassLibrary\QwirkleClassLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>

@ -0,0 +1,15 @@
using QwirkleClassLibrary;
namespace TestBase
{
public class UnitTest1
{
public void Test_PlayerRemoveTile(bool expectedResult)
{
Tile t = new Tile(Square, Red);
Player p = new Player("Patrick");
bool result = p.RemoveTilePlayer(t);
Assert.True(result);
}
}
}
Loading…
Cancel
Save