Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailShichko committed Apr 5, 2022
1 parent c7afad0 commit 79b46d7
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Task3.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 16
VisualStudioVersion = 16.0.32126.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Task3", "Task3\Task3.csproj", "{98A53B70-B70A-4BEA-B614-0870C6C77492}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{98A53B70-B70A-4BEA-B614-0870C6C77492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98A53B70-B70A-4BEA-B614-0870C6C77492}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98A53B70-B70A-4BEA-B614-0870C6C77492}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98A53B70-B70A-4BEA-B614-0870C6C77492}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {85C7571E-CA63-4BAF-AAB2-13BE03E8F567}
EndGlobalSection
EndGlobal
16 changes: 16 additions & 0 deletions Task3/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace Task3
{
class Program
{
static void Main(string[] args)
{
var t = new Table(new string[] { "1", "2", "3", "4", "5"});
t.ShowTable();



}
}
}
69 changes: 69 additions & 0 deletions Task3/Rules.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
namespace Task3
{
public class Rules
{

private void FillTable(Table table)
{
for (int i = 1, j = 0; i < table.GetLength(0); i++, j++)
{
table[0, i] = args[j];
table[i, 0] = args[j];
}

for (int i = 1; i < table.GetLength(0); i++)
{
for (int j = 1; j < table.GetLength(1); j++)
{
switch (Win(i - 1, j - 1))
{
case 1:
table[i, j] = "Win";
break;
case 0:
table[i, j] = "Draw";
break;
case -1:
table[i, j] = "Lose";
break;
}
}
}
}

public int GetRules(int ind1, int ind2, int length)
{
int len = (length - 1) / 2;
if (ind1 < ind2)
{
if (ind1 + len >= ind2)
{
return 1;
}
else
{
return -1;
}

}
else if (ind1 > ind2)
{
if (ind1 + len >= length)
{
int delta = ind1 + len - length;
if (delta >= ind2)
{
return 1;
}
else
{
return -1;
}
}
else return -1;
}

return 0;
}
}
}
205 changes: 205 additions & 0 deletions Task3/Table.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Task3
{
class Table
{
private string[,] table;
private string[] args;
public int X { get; private set; }
public int Y { get; private set; }
public Table(string[] args)
{
table = new string[args.Length + 1, args.Length + 1];
X = args.Length + 1;
this.args = args;
this.FillTable();
}

public void Insert(int x, int y, string value)
{
table[x, y] = value;
}

private void FillTable()
{
for(int i = 1, j = 0; i < table.GetLength(0); i++, j++)
{
table[0, i] = args[j];
table[i, 0] = args[j];
}

for(int i = 1; i < table.GetLength(0); i++)
{
for(int j = 1; j < table.GetLength(1); j++)
{
switch (Win(i - 1,j - 1))
{
case 1:
table[i, j] = "Win";
break;
case 0:
table[i, j] = "Draw";
break;
case -1:
table[i, j] = "Lose";
break;
}
}
}
}

private int Win(int ind1, int ind2)
{
int len = (args.Length - 1) / 2;
if(ind1 < ind2)
{
if(ind1 + len >= ind2)
{
return 1;
}
else
{
return -1;
}

}
else if(ind1 > ind2)
{
if(ind1 + len >= args.Length)
{
int delta = ind1 + len - args.Length;
if(delta >= ind2)
{
return 1;
}
else
{
return -1;
}
}
else return -1;
}

return 0;
}

public void ShowTable()
{
for(int i = 0; i < table.GetLength(0); i++)
{
for(int j = 0; j < table.GetLength(1); j++)
{
Console.Write("{0, -12}|", table[i, j]);
}

Console.Write("\n");
}
}
}
}












/*class Table
{
private string[,] table;
private string[] args;
public int X { get; private set; }
public Table(string[] args)
{
table = new string[args.Length + 1, args.Length + 1];
X = args
this.args = args;
this.FillTable();
}
private void FillTable()
{
for(int i = 1, j = 0; i < table.GetLength(0); i++, j++)
{
table[0, i] = args[j];
table[i, 0] = args[j];
}
for(int i = 1; i < table.GetLength(0); i++)
{
for(int j = 1; j < table.GetLength(1); j++)
{
switch (Win(i - 1,j - 1))
{
case 1:
table[i, j] = "Win";
break;
case 0:
table[i, j] = "Draw";
break;
case -1:
table[i, j] = "Lose";
break;
}
}
}
}
private int Win(int ind1, int ind2)
{
int len = (args.Length - 1) / 2;
if(ind1 < ind2)
{
if(ind1 + len >= ind2)
{
return 1;
}
else
{
return -1;
}
}
else if(ind1 > ind2)
{
if(ind1 + len >= args.Length)
{
int delta = ind1 + len - args.Length;
if(delta >= ind2)
{
return 1;
}
else
{
return -1;
}
}
else return -1;
}
return 0;
}
public void ShowTable()
{
for(int i = 0; i < table.GetLength(0); i++)
{
for(int j = 0; j < table.GetLength(1); j++)
{
Console.Write("{0, -12}|", table[i, j]);
}
Console.Write("\n");
}
}
}*/
8 changes: 8 additions & 0 deletions Task3/Task3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>

0 comments on commit 79b46d7

Please sign in to comment.