diff --git a/Recursion/LD_24/Code/BestPizzeriaResult.cs b/Recursion/LD_24/Code/BestPizzeriaResult.cs
index 254c811..252eda6 100644
--- a/Recursion/LD_24/Code/BestPizzeriaResult.cs
+++ b/Recursion/LD_24/Code/BestPizzeriaResult.cs
@@ -5,10 +5,22 @@ using System.Web;
namespace LD_24.Code
{
+ ///
+ /// Used for keeping the result of path finding
+ ///
public class BestPizzeriaResult
{
+ ///
+ /// Pizzeria to which every friend will go
+ ///
public Point Pizzeria { get; private set; }
+ ///
+ /// Meeting spot for friends
+ ///
public Point MeetingSpot { get; private set; }
+ ///
+ /// The turn number of steps that will be taken between all friends
+ ///
public int Cost { get; private set; }
public BestPizzeriaResult(Point pizzeria, Point meetingSpot, int cost)
@@ -17,5 +29,10 @@ namespace LD_24.Code
MeetingSpot = meetingSpot;
Cost = cost;
}
+
+ public override string ToString()
+ {
+ return String.Format("BestPizzeriaResult{Pizzeria = {0}, MeetingSpot = {1}, Cost = {2}}", Pizzeria, MeetingSpot, Cost);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/Code/InOutUtils.cs b/Recursion/LD_24/Code/InOutUtils.cs
index 9e4afcb..ba5159c 100644
--- a/Recursion/LD_24/Code/InOutUtils.cs
+++ b/Recursion/LD_24/Code/InOutUtils.cs
@@ -6,8 +6,17 @@ using System.Web;
namespace LD_24.Code
{
- public class InOutUtils
+ ///
+ /// Functions related to working with files
+ ///
+ public static class InOutUtils
{
+ ///
+ /// Read a map from a file
+ ///
+ /// Target file
+ /// A map loaded from the file
+ /// If there was an invalid tile
public static Map ReadMap(string filename)
{
string[] lines = File.ReadAllLines(filename);
@@ -42,6 +51,11 @@ namespace LD_24.Code
return map;
}
+ ///
+ /// Write a map to a file
+ ///
+ /// Target file writer
+ /// Target map
public static void WriteMap(StreamWriter writer, Map map)
{
for (int y = 0; y < map.Height; y++)
@@ -74,6 +88,11 @@ namespace LD_24.Code
}
}
+ ///
+ /// Write out best pizzeria result to file
+ ///
+ /// Target file
+ /// Target result
public static void WriteBestPizzeriaResult(StreamWriter writer, BestPizzeriaResult result)
{
if (result == null)
@@ -88,6 +107,11 @@ namespace LD_24.Code
}
}
+ ///
+ /// Write out friend positions to file
+ ///
+ /// Target file
+ /// Target friends list
public static void WriteFriendPositions(StreamWriter writer, List friends)
{
foreach (var friend in friends)
@@ -96,4 +120,4 @@ namespace LD_24.Code
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/Code/Map.cs b/Recursion/LD_24/Code/Map.cs
index 4736468..7bb6e9d 100644
--- a/Recursion/LD_24/Code/Map.cs
+++ b/Recursion/LD_24/Code/Map.cs
@@ -1,16 +1,30 @@
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Web;
namespace LD_24.Code
{
+ ///
+ /// Class used to store a single map
+ ///
public class Map
{
+ ///
+ /// Tile map
+ ///
MapTile[,] data;
+ ///
+ /// Map width
+ ///
public int Width { get; set; }
+ ///
+ /// Map height
+ ///
public int Height { get; set; }
+ ///
+ /// Create an empty map
+ ///
+ /// Target width
+ /// Target height
public Map(int width, int height)
{
data = new MapTile[width, height];
@@ -18,21 +32,44 @@ namespace LD_24.Code
Height = height;
}
+ ///
+ /// Change a single tile in map
+ ///
+ /// Target x
+ /// Target y
+ /// Target tile
public void Set(int x, int y, MapTile tile)
{
data[x, y] = tile;
}
+ ///
+ /// Retrieve a single tile from map
+ ///
+ /// Target x
+ /// Target y
+ /// Tile at target position
public MapTile Get(int x, int y)
{
return data[x, y];
}
+ ///
+ /// Check if a position is whithin the bounds of the map
+ ///
+ ///
+ ///
+ ///
public bool IsInBounds(int x, int y)
{
return x >= 0 && x < Width && y >= 0 && y < Height;
}
+ ///
+ /// Find all positions of a certain tile type
+ ///
+ ///
+ ///
public List FindAll(MapTile tile)
{
List points = new List();
@@ -48,5 +85,10 @@ namespace LD_24.Code
}
return points;
}
+
+ public override string ToString()
+ {
+ return string.Format("Map{Width = {0}, Height = {1}}", Width, Height);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/Code/MapTile.cs b/Recursion/LD_24/Code/MapTile.cs
index 1cb54bb..3882d8f 100644
--- a/Recursion/LD_24/Code/MapTile.cs
+++ b/Recursion/LD_24/Code/MapTile.cs
@@ -5,6 +5,9 @@ using System.Web;
namespace LD_24.Code
{
+ ///
+ /// Enum for storing the type of each tile in a map
+ ///
public enum MapTile
{
Empty,
@@ -13,4 +16,4 @@ namespace LD_24.Code
Pizzeria,
MeetingSpot
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/Code/Point.cs b/Recursion/LD_24/Code/Point.cs
index d9e22f0..4e7bdea 100644
--- a/Recursion/LD_24/Code/Point.cs
+++ b/Recursion/LD_24/Code/Point.cs
@@ -5,9 +5,18 @@ using System.Web;
namespace LD_24.Code
{
+ ///
+ /// A simple point class for storing x and y together.
+ ///
public class Point
{
+ ///
+ /// The x component
+ ///
public int X { get; set; }
+ ///
+ /// The y component
+ ///
public int Y { get; set; }
public Point(int x, int y)
@@ -16,6 +25,11 @@ namespace LD_24.Code
Y = y;
}
+ ///
+ /// Check if 2 points are the same
+ ///
+ /// Other point
+ /// Are the x and y the same
public override bool Equals(object obj)
{
return obj is Point point &&
@@ -31,5 +45,9 @@ namespace LD_24.Code
return hashCode;
}
+ public override string ToString()
+ {
+ return String.Format("Point({0}, {1})", X, Y);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/Code/TaskUtils.cs b/Recursion/LD_24/Code/TaskUtils.cs
index 65c6e88..b907b0f 100644
--- a/Recursion/LD_24/Code/TaskUtils.cs
+++ b/Recursion/LD_24/Code/TaskUtils.cs
@@ -6,7 +6,7 @@ using System.Web;
namespace LD_24.Code
{
- public class TaskUtils
+ public static class TaskUtils
{
public static BestPizzeriaResult FindBestPizzeria(Map map)
{
@@ -112,4 +112,4 @@ namespace LD_24.Code
}
}
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/Forma1-helper.aspx.cs b/Recursion/LD_24/Forma1-helper.aspx.cs
new file mode 100644
index 0000000..d99a929
--- /dev/null
+++ b/Recursion/LD_24/Forma1-helper.aspx.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace LD_24
+{
+ public partial class Forma1 : System.Web.UI.Page
+ {
+ ///
+ /// Put target friends into a bulleted list element
+ ///
+ /// Target list
+ /// Target friends
+ private void ShowFriends(BulletedList list, List friends)
+ {
+ list.Items.Clear();
+ foreach (var friend in friends)
+ {
+ list.Items.Add(String.Format("X = {0}, Y = {1}", friend.X + 1, friend.Y + 1));
+ }
+ }
+
+ ///
+ /// Put best pizzeria result into a label
+ ///
+ /// Target label
+ /// Target result
+ private void ShowBestPizzeriaResult(Label label, Code.BestPizzeriaResult result)
+ {
+ if (result == null)
+ {
+ label.Text = "Neįmanoma";
+ return;
+ }
+
+ label.Text = String.Format("Susitikimo vieta (X = {0}, Y = {1})", result.MeetingSpot.X + 1, result.MeetingSpot.Y + 1);
+ label.Text += "
";
+ label.Text += String.Format("Picerija (X = {0}, Y = {1})", result.Pizzeria.X + 1, result.Pizzeria.Y + 1);
+ label.Text += "
";
+ label.Text += String.Format("Nueita {0}", result.Cost);
+ }
+
+ ///
+ /// Put a maps tiles into a table
+ ///
+ /// Target table
+ /// Target map
+ private void ShowMap(Table table, Code.Map map)
+ {
+ table.Rows.Clear();
+ for (int y = 0; y < map.Height; y++)
+ {
+ TableRow row = new TableRow();
+ for (int x = 0; x < map.Width; x++)
+ {
+ TableCell cell = new TableCell();
+ cell.Width = 20;
+ cell.Height = 20;
+ switch (map.Get(x, y))
+ {
+ case Code.MapTile.Empty:
+ cell.Text = ".";
+ break;
+ case Code.MapTile.Pizzeria:
+ cell.Text = "P";
+ break;
+ case Code.MapTile.Friend:
+ cell.Text = "D";
+ break;
+ case Code.MapTile.MeetingSpot:
+ cell.Text = "S";
+ break;
+ case Code.MapTile.Wall:
+ cell.Text = "X";
+ break;
+ default:
+ cell.Text = "?";
+ break;
+ }
+ row.Cells.Add(cell);
+ }
+ table.Rows.Add(row);
+ }
+ }
+ }
+}
diff --git a/Recursion/LD_24/Forma1.aspx.cs b/Recursion/LD_24/Forma1.aspx.cs
index 83413a2..bb28863 100644
--- a/Recursion/LD_24/Forma1.aspx.cs
+++ b/Recursion/LD_24/Forma1.aspx.cs
@@ -8,12 +8,18 @@ using System.Web.UI.WebControls;
namespace LD_24
{
+
public partial class Forma1 : System.Web.UI.Page
{
private string inputFilename;
private string outputFilename;
private Code.Map map;
+ ///
+ /// Load initial map and show it in the interface
+ ///
+ /// Sender element
+ /// Event
protected void Page_Load(object sender, EventArgs e)
{
inputFilename = Server.MapPath(@"App_Data/U3.txt");
@@ -22,7 +28,13 @@ namespace LD_24
map = Code.InOutUtils.ReadMap(inputFilename);
ShowMap(Table1, map);
}
-
+
+ ///
+ /// Find which is the best pizzeria, show it in the interface and output the result
+ /// to a file
+ ///
+ /// Sender element
+ /// Event
protected void Button1_Click(object sender, EventArgs e)
{
List friends = map.FindAll(Code.MapTile.Friend);
@@ -43,67 +55,5 @@ namespace LD_24
Code.InOutUtils.WriteBestPizzeriaResult(writer, result);
}
}
-
- private void ShowFriends(BulletedList list, List friends)
- {
- list.Items.Clear();
- foreach (var friend in friends)
- {
- list.Items.Add(String.Format("X = {0}, Y = {1}", friend.X + 1, friend.Y + 1));
- }
- }
-
- private void ShowBestPizzeriaResult(Label label, Code.BestPizzeriaResult result)
- {
- if (result == null)
- {
- label.Text = "Neįmanoma";
- return;
- }
-
- label.Text = String.Format("Susitikimo vieta (X = {0}, Y = {1})", result.MeetingSpot.X + 1, result.MeetingSpot.Y + 1);
- label.Text += "
";
- label.Text += String.Format("Picerija (X = {0}, Y = {1})", result.Pizzeria.X + 1, result.Pizzeria.Y + 1);
- label.Text += "
";
- label.Text += String.Format("Nueita {0}", result.Cost);
- }
-
- private void ShowMap(Table table, Code.Map map)
- {
- table.Rows.Clear();
- for (int y = 0; y < map.Height; y++)
- {
- TableRow row = new TableRow();
- for (int x = 0; x < map.Width; x++)
- {
- TableCell cell = new TableCell();
- cell.Width = 20;
- cell.Height = 20;
- switch (map.Get(x, y))
- {
- case Code.MapTile.Empty:
- cell.Text = ".";
- break;
- case Code.MapTile.Pizzeria:
- cell.Text = "P";
- break;
- case Code.MapTile.Friend:
- cell.Text = "D";
- break;
- case Code.MapTile.MeetingSpot:
- cell.Text = "S";
- break;
- case Code.MapTile.Wall:
- cell.Text = "X";
- break;
- default:
- cell.Text = "?";
- break;
- }
- row.Cells.Add(cell);
- }
- table.Rows.Add(row);
- }
- }
}
-}
\ No newline at end of file
+}
diff --git a/Recursion/LD_24/LD_24.csproj b/Recursion/LD_24/LD_24.csproj
index cd05188..caea5eb 100644
--- a/Recursion/LD_24/LD_24.csproj
+++ b/Recursion/LD_24/LD_24.csproj
@@ -7,13 +7,13 @@
2.0
- {6AAB1A29-81E1-4A08-A8C3-9C203C684B8F}
+ {4E9466EF-CDF4-4620-B51E-125F5A014A04}
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
Library
Properties
LD_24
LD_24
- v4.7.2
+ v4.8
true
@@ -71,6 +71,11 @@
+
+
+
+
+
@@ -80,6 +85,9 @@
+
+ ASPXCodeBehind
+
Forma1.aspx
ASPXCodeBehind
@@ -98,7 +106,6 @@
Web.config
-
10.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
@@ -112,9 +119,9 @@
True
True
- 57614
+ 51983
/
- http://localhost:44363/
+ http://localhost:44364/
False
False
diff --git a/Recursion/LD_24/Properties/AssemblyInfo.cs b/Recursion/LD_24/Properties/AssemblyInfo.cs
index bf445ad..077fd0f 100644
--- a/Recursion/LD_24/Properties/AssemblyInfo.cs
+++ b/Recursion/LD_24/Properties/AssemblyInfo.cs
@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("6aab1a29-81e1-4a08-a8c3-9c203c684b8f")]
+[assembly: Guid("4e9466ef-cdf4-4620-b51e-125f5a014a04")]
// Version information for an assembly consists of the following four values:
//
diff --git a/Recursion/LD_24/Web.config b/Recursion/LD_24/Web.config
index 2d1c85e..a190051 100644
--- a/Recursion/LD_24/Web.config
+++ b/Recursion/LD_24/Web.config
@@ -5,8 +5,8 @@
-->
-
-
+
+
@@ -15,4 +15,4 @@
-
\ No newline at end of file
+
diff --git a/Recursion/LD_24/packages.config b/Recursion/LD_24/packages.config
index 55d586f..96a3cec 100644
--- a/Recursion/LD_24/packages.config
+++ b/Recursion/LD_24/packages.config
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/Recursion/Recursion.sln b/Recursion/Recursion.sln
index 138946f..b9146af 100644
--- a/Recursion/Recursion.sln
+++ b/Recursion/Recursion.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{6AAB1A29-81E1-4A08-A8C3-9C203C684B8F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{4E9466EF-CDF4-4620-B51E-125F5A014A04}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,10 +11,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {6AAB1A29-81E1-4A08-A8C3-9C203C684B8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6AAB1A29-81E1-4A08-A8C3-9C203C684B8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6AAB1A29-81E1-4A08-A8C3-9C203C684B8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6AAB1A29-81E1-4A08-A8C3-9C203C684B8F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4E9466EF-CDF4-4620-B51E-125F5A014A04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4E9466EF-CDF4-4620-B51E-125F5A014A04}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4E9466EF-CDF4-4620-B51E-125F5A014A04}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4E9466EF-CDF4-4620-B51E-125F5A014A04}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE