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
Binary file modified .vs/Snake/v16/.suo
Binary file not shown.
Binary file modified .vs/Snake/v16/Server/sqlite3/storage.ide
Binary file not shown.
Binary file added .vs/Snake/v16/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file added .vs/Snake/v16/Server/sqlite3/storage.ide-wal
Binary file not shown.
37 changes: 37 additions & 0 deletions Snake/Point.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Snake
{
class Point
{
//private int x;
//private int y;
// Временно делаем поля открытыми
public int x;
public int y;
private char sym;

public Point()
{

}

public Point(int x, int y, char sym)
{
this.x = x;
this.y = y;
this.sym = sym;
}

public void Draw()
{
Console.SetCursorPosition(x, y);
Console.Write(sym);
}
}

}
55 changes: 50 additions & 5 deletions Snake/Program.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Snake
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");

Point p1 = new Point(1, 3, '*');
p1.Draw();

Point p2 = new Point(4, 5, '#');
p2.Draw();

int x = 1;
Func1(x);
Console.WriteLine($"Func1 x={x}");

Func2(x);
Console.WriteLine($"Func2 x={x}");

Func3(x);
Console.WriteLine($"Func3 x={x}");

Move(p1, 10, 10);
Console.WriteLine($"Move(p1, 10, 10) p1.x = {p1.x}, p1.y = {p1.y}");

Reset(p2);
Console.WriteLine($"Reset(p2) p2.x = {p2.x}, p2.y = {p2.y}");

Console.ReadKey();
}

private static void Reset(Point p)
{
p = new Point();
// Здесь переменная p2 останется без изменений.
}

private static void Move(Point p, int dx, int dy)
{
p.x = p.x + dx;
p.y = p.y + dy;
}

private static void Func3(int x)
{
x++;
}

private static void Func2(int val)
{
val++;
}

private static void Func1(int x)
{

}
}
}
1 change: 1 addition & 0 deletions Snake/Snake.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Point.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
Binary file modified Snake/bin/Debug/Snake.exe
Binary file not shown.
Binary file modified Snake/bin/Debug/Snake.pdb
Binary file not shown.
Binary file modified Snake/obj/Debug/Snake.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified Snake/obj/Debug/Snake.exe
Binary file not shown.
Binary file modified Snake/obj/Debug/Snake.pdb
Binary file not shown.