1
0

Compare commits

...

10 Commits

48 changed files with 1592 additions and 236 deletions

View File

@ -11,11 +11,14 @@ on:
push:
branches: [ main ]
paths:
- '.github/workflows/generate-and-upload.yml'
- 'report.toml'
- 'L1/LD_24/**'
- 'L2/LD_24/**'
- 'L3/LD_24/**'
- 'L3/LD_24Tests/**'
- 'L4/LD_24/**'
- 'L4/LD_24Tests/**'
jobs:
generate-and-upload:
@ -24,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Generate report
uses: RokasPuzonas/ktu-oop-report-generator@v2.0.8
uses: RokasPuzonas/ktu-oop-report-generator@v2.0.10
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
config-filename: ${{ env.CONFIG_FILENAME }}

View File

@ -2,7 +2,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -13,7 +13,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LD_24</RootNamespace>
<AssemblyName>LD_24</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />
@ -23,6 +23,7 @@
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -32,6 +33,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -41,15 +43,10 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
@ -7,9 +7,17 @@
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.6" />
</system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.6.1"/>
<compilation debug="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
<globalization fileEncoding="utf-8"/>
</system.web>
<system.codedom>
@ -18,7 +26,6 @@
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net461" />
<package id="System.Threading.Tasks.Extensions" version="4.5.0" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Threading.Tasks.Extensions" version="4.5.0" targetFramework="net461" requireReinstallation="true" />
</packages>

View File

@ -1,14 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bogus" Version="34.0.1" />
<PackageReference Include="FluentAssertions" Version="6.6.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />

31
L4/L4.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24Tests", "LD_24Tests\LD_24Tests.csproj", "{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Release|Any CPU.Build.0 = Release|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1567F9E-F2A5-48D9-B581-1B76DEC9F21E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {311CB727-13E2-47BB-8B1B-0C68CF29441E}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,7 @@
Elf
Konopelskitown
Gail;Mage;6;23;24;17;Hand, Cummerata and Wolff
Garret;Mage;5;11;1;10;13;22;14;4
Maybelle;Hunter;21;11;25;17;24;25;5;5
Amy;Warrior;11;5;13;15;12;4;3;23
Natalie;Warrior;18;23;25;14;West Inc

View File

@ -0,0 +1,5 @@
Elf
Port Sierraton
Lyla;Archer;5;10;5;21;Crona - Abshire
Ruthe;Necromancer;7;21;11;10;McDermott, Satterfield and Reichel
Berneice;Mage;6;23;23;6;Sawayn - Kovacek

View File

@ -0,0 +1,7 @@
Orc
North Anastacio
Will;Mage;18;24;21;3;25;17;4;21
Brennan;Mage;2;5;4;8;Lindgren, Spinka and Walsh
Jannie;Hunter;15;5;25;10;Kub - Flatley
Nicolette;Archer;11;9;3;17;16;10;18;15
Noe;Warrior;3;7;14;16;Bradtke, Deckow and Larson

View File

@ -0,0 +1,5 @@
Mage
Hunter
Warrior
Archer
Necromancer
1 Mage
2 Hunter
3 Warrior
4 Archer
5 Necromancer

View File

@ -0,0 +1,2 @@
Orc;North Anastacio;Brennan;Mage;2;5;4;8;Lindgren, Spinka and Walsh
Elf;Port Sierraton;Lyla;Archer;5;10;5;21;Crona - Abshire
1 Orc North Anastacio Brennan Mage 2 5 4 8 Lindgren, Spinka and Walsh
2 Elf Port Sierraton Lyla Archer 5 10 5 21 Crona - Abshire

View File

@ -0,0 +1,2 @@


64
L4/LD_24/Code/Actor.cs Normal file
View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
/// <summary>
/// Abstract actor class
/// </summary>
public abstract class Actor
{
/// <summary>
/// Race of actor
/// </summary>
public string Race { get; set; }
/// <summary>
/// Starting town of actor
/// </summary>
public string StartingTown { get; set; }
/// <summary>
/// Name of actor
/// </summary>
public string Name { get; set; }
/// <summary>
/// Class of actor
/// </summary>
public string Class { get; set; }
/// <summary>
/// Health points of actor
/// </summary>
public int Health { get; set; }
/// <summary>
/// Mana points of actor
/// </summary>
public int Mana { get; set; }
/// <summary>
/// Attack points of actor
/// </summary>
public int Attack { get; set; }
/// <summary>
/// Defense points of actor
/// </summary>
public int Defense { get; set; }
public Actor(string race, string startingTown, string name, string @class, int health, int mana, int attack, int defense)
{
Race = race;
StartingTown = startingTown;
Name = name;
Class = @class;
Health = health;
Mana = mana;
Attack = attack;
Defense = defense;
}
/// <summary>
/// Serialize an actor into a valid CSV line
/// </summary>
/// <returns>A string representing the whole actor</returns>
public abstract string ToCSVLine();
}
}

67
L4/LD_24/Code/Hero.cs Normal file
View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
/// <summary>
/// Class for a single hero
/// </summary>
public class Hero : Actor, IComparable<Hero>, IEquatable<Hero>
{
/// <summary>
/// Power points of hero
/// </summary>
public int Power { get; set; }
/// <summary>
/// Agility points of hero
/// </summary>
public int Agility { get; set; }
/// <summary>
/// Intellect points of hero
/// </summary>
public int Intellect { get; set; }
/// <summary>
/// Special points of hero
/// </summary>
public int Special { get; set; }
public Hero(string race, string startingTown, string name, string @class, int health, int mana, int attack, int defense, int power, int agility, int intellect, int special) : base(race, startingTown, name, @class, health, mana, attack, defense)
{
Power = power;
Agility = agility;
Intellect = intellect;
Special = special;
}
/// <summary>
/// Compare hero to hero by intellect
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public int CompareTo(Hero other)
{
return Intellect.CompareTo(other.Intellect);
}
/// <summary>
/// Check if 2 heros have the same intellect
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public bool Equals(Hero other)
{
return Intellect.Equals(other.Intellect);
}
/// <summary>
/// Serialize a hero to a CSV line
/// </summary>
/// <returns></returns>
public override string ToCSVLine()
{
return string.Join(";", Race, StartingTown, Name, Class, Health, Mana, Attack, Defense, Power, Agility, Intellect, Special);
}
}
}

188
L4/LD_24/Code/InOutUtils.cs Normal file
View File

@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Diagnostics;
using Bogus;
using System.Text;
namespace LD_24.Code
{
/// <summary>
/// Utility class for reading/writing to files
/// </summary>
public static class InOutUtils
{
private static readonly List<string> Races = new List<string> { "Human", "Orc", "Elf", "Dwarf", "Fairy", "Halfling" };
private static readonly List<string> Classess = new List<string> { "Warrior", "Hunter", "Archer", "Mage", "Necromancer" };
private static readonly Faker faker = new Faker();
/// <summary>
/// Read line by lines from a file
/// </summary>
/// <param name="filename">Target file</param>
/// <returns>Lines</returns>
public static IEnumerable<string> ReadLines(string filename)
{
using (var reader = new StreamReader(filename))
{
string line;
while ((line = reader.ReadLine()) != null)
{
// This check is for ignoring empty lines
if (line.Length > 0)
{
yield return line;
}
}
}
}
/// <summary>
/// Read actors from a file
/// </summary>
/// <param name="filename">Target file</param>
/// <returns>A list of actors</returns>
/// <exception cref="Exception">Throws if a given line in a file is incorrect</exception>
public static List<Actor> ReadActors(string filename)
{
var actors = new List<Actor>();
var lines = ReadLines(filename);
var race = lines.First().Trim();
var startingTown = lines.Skip(1).First().Trim();
foreach (var line in lines.Skip(2))
{
string[] parts = line.Split(';');
if (parts.Length != 7 && parts.Length != 10)
{
throw new Exception($"Invalid number of values given: '{line}'");
}
string name = parts[0].Trim();
string @class = parts[1].Trim();
int health = int.Parse(parts[2]);
int mana = int.Parse(parts[3]);
int attack = int.Parse(parts[4]);
int defense = int.Parse(parts[5]);
if (parts.Length == 7)
{
string guild = parts[6].Trim();
actors.Add(new NPC(race, startingTown, name, @class, health, mana, attack, defense, guild));
}
else if (parts.Length == 10)
{
int power = int.Parse(parts[6]);
int agility = int.Parse(parts[7]);
int intellect = int.Parse(parts[8]);
int special = int.Parse(parts[9]);
actors.Add(new Hero(race, startingTown, name, @class, health, mana, attack, defense, power, agility, intellect, special));
}
}
return actors;
}
/// <summary>
/// Generate file with actors
/// </summary>
/// <param name="filename">Target file</param>
public static void GenerateFakeActors(string filename)
{
using (var writer = new StreamWriter(filename))
{
writer.WriteLine(faker.PickRandom(Races));
writer.WriteLine(faker.Address.City());
int count = faker.Random.Number(1, 5);
for (int i = 0; i < count; i++)
{
string name = faker.Name.FirstName();
string @class = faker.PickRandom(Classess);
int health = faker.Random.Number(1, 25);
int mana = faker.Random.Number(1, 25);
int attack = faker.Random.Number(1, 25);
int defense = faker.Random.Number(1, 25);
writer.Write($"{name};{@class};{health};{mana};{attack};{defense};");
if (faker.Random.Number(100) < 60)
{
string guild = faker.Company.CompanyName();
writer.WriteLine($"{guild}");
} else
{
int power = faker.Random.Number(1, 25);
int agility = faker.Random.Number(1, 25);
int intellect = faker.Random.Number(1, 25);
int special = faker.Random.Number(1, 25);
writer.WriteLine($"{power};{agility};{intellect};{special}");
}
}
}
}
/// <summary>
/// Read all files from a directory that have actors
/// </summary>
/// <param name="directory"></param>
/// <param name="pattern"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static List<Actor> ReadActorsDir(string directory, string pattern = "*.txt")
{
if (!Directory.Exists(directory))
{
throw new Exception(string.Format("Directory '{0}' not found", directory));
}
var merged = new List<Actor>();
foreach (var filename in Directory.GetFiles(directory, pattern))
{
merged.AddRange(ReadActors(filename));
}
return merged;
}
/// <summary>
/// Writes a list of classes to a file
/// </summary>
/// <param name="filename">Target file</param>
/// <param name="classes">Target classes</param>
public static void PrintClassesCSV(string filename, List<string> classes)
{
using (var writer = new StreamWriter(filename, false, Encoding.UTF8))
{
foreach (var @class in classes)
{
writer.WriteLine(@class);
}
}
}
/// <summary>
/// Prints missing actors to a file
/// </summary>
/// <param name="filename">Target file</param>
/// <param name="missingActors">Missing actor race names</param>
public static void PrintMissingActors(string filename, Tuple<List<string>, List<string>> missingActors)
{
using (var writer = new StreamWriter(filename, false, Encoding.UTF8))
{
writer.WriteLine(string.Join(";", missingActors.Item1));
writer.WriteLine(string.Join(";", missingActors.Item2));
}
}
/// <summary>
/// Prints a team of actors to a file
/// </summary>
/// <param name="filename">Target file</param>
/// <param name="team">Target actors</param>
public static void PrintTeam(string filename, List<Actor> team)
{
using (var writer = new StreamWriter(filename, false, Encoding.UTF8))
{
foreach (var actor in team)
{
writer.WriteLine(actor.ToCSVLine());
}
}
}
}
}

52
L4/LD_24/Code/NPC.cs Normal file
View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
/// <summary>
/// Class for storing a single NPC
/// </summary>
public class NPC : Actor, IComparable<NPC>, IEquatable<NPC>
{
/// <summary>
/// blah blah blah blah
/// </summary>
public string Guild { get; set; }
public NPC(string race, string startingTown, string name, string @class, int health, int mana, int attack, int defense, string guild) : base(race, startingTown, name, @class, health, mana, attack, defense)
{
Guild = guild;
}
/// <summary>
/// blah blah
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public int CompareTo(NPC other)
{
return Attack.CompareTo(other.Attack);
}
/// <summary>
/// blah blah blah
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public bool Equals(NPC other)
{
return Attack.Equals(other.Attack);
}
/// <summary>
/// blah blah?
/// </summary>
/// <returns></returns>
public override string ToCSVLine()
{
return string.Join(";", Race, StartingTown, Name, Class, Health, Mana, Attack, Defense, Guild);
}
}
}

151
L4/LD_24/Code/TaskUtils.cs Normal file
View File

@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
/// <summary>
/// Utility class for storing unrelated methods
/// </summary>
public static class TaskUtils
{
/// <summary>
/// Find the actors which have the most health by class
/// </summary>
/// <param name="actors"></param>
/// <returns></returns>
public static Dictionary<string, int> FindMostHealthByClass(List<Actor> actors)
{
Dictionary<string, int> mostHealth = new Dictionary<string, int>();
foreach (var actor in actors)
{
if (mostHealth.ContainsKey(actor.Class))
{
mostHealth[actor.Class] = Math.Max(mostHealth[actor.Class], actor.Health);
} else
{
mostHealth.Add(actor.Class, actor.Health);
}
}
return mostHealth;
}
/// <summary>
/// Find all unique classes from a list of actors
/// </summary>
/// <param name="actors"></param>
/// <returns></returns>
public static List<string> FindAllClasses(List<Actor> actors)
{
List<string> result = new List<string>();
foreach (var actor in actors)
{
if (!result.Contains(actor.Class))
{
result.Add(actor.Class);
}
}
return result;
}
/// <summary>
/// Find all unique races from a list of actors
/// </summary>
/// <param name="actors"></param>
/// <returns></returns>
public static List<string> FindAllRaces(List<Actor> actors)
{
List<string> races = new List<string>();
foreach (var actor in actors)
{
if (!races.Contains(actor.Race))
{
races.Add(actor.Race);
}
}
return races;
}
/// <summary>
/// Finds which races are missing an NPC or Hero
/// </summary>
/// <param name="actors"></param>
/// <returns>A tuple where Item1 is missing Heros, and Item2 is missing NPCs</returns>
public static Tuple<List<string>, List<string>> FindMissingActors(List<Actor> actors)
{
var races = FindAllRaces(actors);
var missingHeroes = races;
var missingNPCs = new List<string>(races);
foreach (var actor in actors)
{
if (actor is Hero)
{
missingHeroes.Remove(actor.Race);
} else if (actor is NPC)
{
missingNPCs.Remove(actor.Race);
}
}
return Tuple.Create(missingHeroes, missingNPCs);
}
/// <summary>
/// Find the actors which have the most health in their respective classes
/// </summary>
/// <param name="actors"></param>
/// <returns></returns>
public static List<Actor> FilterMostHealthByClass(List<Actor> actors)
{
List<Actor> filtered = new List<Actor>();
var mostHealths = FindMostHealthByClass(actors);
foreach (var actor in actors)
{
if (mostHealths[actor.Class] == actor.Health)
{
filtered.Add(actor);
}
}
return filtered;
}
/// <summary>
/// Filter out heros which, don't meet the min intellect (exclusively)
/// </summary>
/// <param name="actors"></param>
/// <param name="minIntellect"></param>
/// <returns></returns>
public static List<Hero> FilterHeroesByIntellect(List<Actor> actors, int minIntellect)
{
List<Hero> filtered = new List<Hero>();
foreach (var actor in actors)
{
if (actor is Hero && (actor as Hero).Intellect > minIntellect)
{
filtered.Add(actor as Hero);
}
}
return filtered;
}
/// <summary>
/// Filter out NPC which, don't meet the max attack (exclusively)
/// </summary>
/// <param name="actors"></param>
/// <param name="maxAttack"></param>
/// <returns></returns>
public static List<NPC> FilterNPCsByAttack(List<Actor> actors, int maxAttack)
{
List<NPC> filtered = new List<NPC>();
foreach (var actor in actors)
{
if (actor is NPC && actor.Attack < maxAttack)
{
filtered.Add(actor as NPC);
}
}
return filtered;
}
}
}

33
L4/LD_24/Forma1.aspx Normal file
View File

@ -0,0 +1,33 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forma1.aspx.cs" Inherits="LD_24.Forma1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="~/Styles/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label3" runat="server" Text="Minimalus herojaus intelekto kiekis:"></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server" TextMode="Number"></asp:TextBox>
<br />
<asp:Label ID="Label4" runat="server" Text="Maksimalus NPC žalos kiekis:"></asp:Label>
<br />
<asp:TextBox ID="TextBox2" runat="server" TextMode="Number"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Vykdyti" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Pradiniai duomenys:"></asp:Label>
<asp:Table ID="Table1" runat="server">
</asp:Table>
<asp:Label ID="Label2" runat="server" Text="Daugiausiai gyvybės taškų pagal klases:"></asp:Label>
<asp:Table ID="Table2" runat="server">
</asp:Table>
</div>
</form>
</body>
</html>

77
L4/LD_24/Forma1.aspx.cs Normal file
View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using LD_24.Code;
using System.Diagnostics;
namespace LD_24
{
/// <summary>
/// Main Form
/// </summary>
public partial class Forma1 : System.Web.UI.Page
{
private List<Actor> actors = null;
protected void Page_Load(object sender, EventArgs e)
{
// Generate initial data files if they don't exist
string[] actorFiles = { "Actors1.txt", "Actors2.txt", "Actors3.txt" };
foreach (string name in actorFiles)
{
string filename = Server.MapPath($"App_Data/{name}");
if (!File.Exists(filename))
{
InOutUtils.GenerateFakeActors(filename);
}
}
// Read actors from folder
try
{
actors = InOutUtils.ReadActorsDir(Server.MapPath("App_Data"));
} catch (Exception ex)
{
Debug.WriteLine("Oops an error occured:");
Debug.WriteLine(ex);
throw ex;
}
Label1.Visible = false;
Label2.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Visible = true;
Label2.Visible = true;
int minHeroIntellect = int.Parse(TextBox1.Text);
int maxNPCAttack = int.Parse(TextBox2.Text);
ShowActors(Table1, actors);
var heatlhyActors = TaskUtils.FilterMostHealthByClass(actors);
ShowHealthyActors(Table2, heatlhyActors);
var allClasses = TaskUtils.FindAllClasses(actors);
InOutUtils.PrintClassesCSV(Server.MapPath("App_Data/Klasės.csv"), allClasses);
var missingActors = TaskUtils.FindMissingActors(actors);
InOutUtils.PrintMissingActors(Server.MapPath("App_Data/Trūkstami.csv"), missingActors);
var intellectHeroes = TaskUtils.FilterHeroesByIntellect(actors, minHeroIntellect);
var strengthNPCs = TaskUtils.FilterNPCsByAttack(actors, maxNPCAttack);
intellectHeroes.Sort();
strengthNPCs.Sort();
var team = new List<Actor>();
team.AddRange(intellectHeroes);
team.AddRange(strengthNPCs);
InOutUtils.PrintTeam(Server.MapPath("App_Data/Riktine.csv"), team);
}
}
}

107
L4/LD_24/Forma1.aspx.designer.cs generated Normal file
View File

@ -0,0 +1,107 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LD_24
{
public partial class Forma1
{
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// Label3 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label3;
/// <summary>
/// TextBox1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox1;
/// <summary>
/// Label4 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label4;
/// <summary>
/// TextBox2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox2;
/// <summary>
/// Button1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button Button1;
/// <summary>
/// Label1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label1;
/// <summary>
/// Table1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Table Table1;
/// <summary>
/// Label2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label2;
/// <summary>
/// Table2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Table Table2;
}
}

86
L4/LD_24/Forma1Utils.cs Normal file
View File

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using LD_24.Code;
namespace LD_24
{
public partial class Forma1 : System.Web.UI.Page
{
/// <summary>
/// Show a table to the Web UI
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="table"></param>
/// <param name="list"></param>
/// <param name="columns"></param>
/// <returns></returns>
public static IEnumerable<Tuple<T, TableCellCollection>> ShowTable<T>(Table table, IEnumerable<T> list, params string[] columns)
{
TableHeaderRow header = new TableHeaderRow();
foreach (string column in columns)
{
header.Cells.Add(new TableHeaderCell { Text = column });
}
table.Rows.Add(header);
bool noRows = true;
foreach (T item in list)
{
TableRow row = new TableRow();
yield return Tuple.Create(item, row.Cells);
table.Rows.Add(row);
noRows = false;
}
if (noRows)
{
TableRow row = new TableRow();
row.Cells.Add(new TableCell { Text = "Nėra", ColumnSpan = columns.Length });
table.Rows.Add(row);
}
}
/// <summary>
/// Show a list of actors in a table
/// </summary>
/// <param name="table"></param>
/// <param name="actors"></param>
public static void ShowActors(Table table, IEnumerable<Actor> actors)
{
foreach (var tuple in ShowTable(table, actors, "Rasė", "Miestas", "Vardas", "Klasė", "Gyvybė", "Mana", "Žala", "Šarvai"))
{
var actor = tuple.Item1;
var cells = tuple.Item2;
cells.Add(new TableCell { Text = actor.Race });
cells.Add(new TableCell { Text = actor.StartingTown });
cells.Add(new TableCell { Text = actor.Name });
cells.Add(new TableCell { Text = actor.Class });
cells.Add(new TableCell { Text = actor.Health.ToString() });
cells.Add(new TableCell { Text = actor.Mana.ToString() });
cells.Add(new TableCell { Text = actor.Attack.ToString() });
cells.Add(new TableCell { Text = actor.Defense.ToString() });
}
}
/// <summary>
/// Show a list of healthy actors to a table
/// </summary>
/// <param name="table"></param>
/// <param name="actors"></param>
public static void ShowHealthyActors(Table table, IEnumerable<Actor> actors)
{
foreach (var tuple in ShowTable(table, actors, "Vardas", "Rasė", "Klasė", "Gyvybė"))
{
var actor = tuple.Item1;
var cells = tuple.Item2;
cells.Add(new TableCell { Text = actor.Name });
cells.Add(new TableCell { Text = actor.Race });
cells.Add(new TableCell { Text = actor.Class });
cells.Add(new TableCell { Text = actor.Health.ToString() });
}
}
}
}

150
L4/LD_24/LD_24.csproj Normal file
View File

@ -0,0 +1,150 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<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>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LD_24</RootNamespace>
<AssemblyName>LD_24</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort>
</IISExpressSSLPort>
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Bogus, Version=34.0.2.0, Culture=neutral, PublicKeyToken=fa1bb3f3f218129a, processorArchitecture=MSIL">
<HintPath>..\packages\Bogus.34.0.2\lib\net40\Bogus.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Forma1.aspx" />
<Content Include="Styles\main.css" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Code\Actor.cs" />
<Compile Include="Code\Hero.cs" />
<Compile Include="Code\InOutUtils.cs" />
<Compile Include="Code\NPC.cs" />
<Compile Include="Code\TaskUtils.cs" />
<Compile Include="Forma1.aspx.cs">
<DependentUpon>Forma1.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Forma1.aspx.designer.cs">
<DependentUpon>Forma1.aspx</DependentUpon>
</Compile>
<Compile Include="Forma1Utils.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="tests\1\inputs\" />
<Folder Include="tests\1\outputs\" />
<Folder Include="tests\2\inputs\" />
<Folder Include="tests\2\outputs\" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>50285</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:44308/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LD_24")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LD_24")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4b4c2bfe-c41e-4ea1-bc86-979e2ca1d27b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

11
L4/LD_24/Styles/main.css Normal file
View File

@ -0,0 +1,11 @@
table, th, td {
border: 1px solid black;
padding: 0.5rem;
border-collapse: collapse;
}
table {
margin-bottom: 1em;
background-color: #FFFFCC;
}

30
L4/LD_24/Web.Debug.config Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>

18
L4/LD_24/Web.config Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
<globalization fileEncoding="utf-8" />
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

5
L4/LD_24/packages.config Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Bogus" version="34.0.2" targetFramework="net46" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net46" />
</packages>

View File

@ -0,0 +1,3 @@
Elf
Padbergborough
Verla;Warrior;16;23;16;23;21;12;2;10

View File

@ -0,0 +1,7 @@
Dwarf
Verdiebury
Toney;Hunter;20;2;9;11;13;6;17;16
Andreanne;Warrior;14;25;6;23;Rempel LLC
Octavia;Necromancer;16;20;13;14;Considine, Runte and Mosciski
Ocie;Warrior;14;16;22;7;14;3;3;18
Vicente;Hunter;16;20;24;3;Farrell, Watsica and O'Keefe

View File

@ -0,0 +1,7 @@
Orc
East Chelseyberg
Shaina;Archer;20;2;23;1;Wintheiser, Heidenreich and Hansen
Lucie;Archer;12;16;14;2;9;5;19;15
Doyle;Archer;12;14;18;3;10;10;18;1
Amir;Mage;15;9;16;2;Steuber Group
Muhammad;Necromancer;2;19;12;2;3;7;22;2

View File

@ -0,0 +1,5 @@
Warrior
Hunter
Necromancer
Archer
Mage
1 Warrior
2 Hunter
3 Necromancer
4 Archer
5 Mage

View File

@ -0,0 +1,7 @@
Elf;Padbergborough;Verla;Warrior;16;23;16;23;21;12;2;10
Dwarf;Verdiebury;Ocie;Warrior;14;16;22;7;14;3;3;18
Dwarf;Verdiebury;Toney;Hunter;20;2;9;11;13;6;17;16
Orc;East Chelseyberg;Doyle;Archer;12;14;18;3;10;10;18;1
Orc;East Chelseyberg;Lucie;Archer;12;16;14;2;9;5;19;15
Orc;East Chelseyberg;Muhammad;Necromancer;2;19;12;2;3;7;22;2
Dwarf;Verdiebury;Andreanne;Warrior;14;25;6;23;Rempel LLC
1 Elf;Padbergborough;Verla;Warrior;16;23;16;23;21;12;2;10
2 Dwarf;Verdiebury;Ocie;Warrior;14;16;22;7;14;3;3;18
3 Dwarf;Verdiebury;Toney;Hunter;20;2;9;11;13;6;17;16
4 Orc;East Chelseyberg;Doyle;Archer;12;14;18;3;10;10;18;1
5 Orc;East Chelseyberg;Lucie;Archer;12;16;14;2;9;5;19;15
6 Orc;East Chelseyberg;Muhammad;Necromancer;2;19;12;2;3;7;22;2
7 Dwarf;Verdiebury;Andreanne;Warrior;14;25;6;23;Rempel LLC

View File

@ -0,0 +1,2 @@

Elf
1 Elf

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,7 @@
Elf
Konopelskitown
Gail;Mage;6;23;24;17;Hand, Cummerata and Wolff
Garret;Mage;5;11;1;10;13;22;14;4
Maybelle;Hunter;21;11;25;17;24;25;5;5
Amy;Warrior;11;5;13;15;12;4;3;23
Natalie;Warrior;18;23;25;14;West Inc

View File

@ -0,0 +1,5 @@
Elf
Port Sierraton
Lyla;Archer;5;10;5;21;Crona - Abshire
Ruthe;Necromancer;7;21;11;10;McDermott, Satterfield and Reichel
Berneice;Mage;6;23;23;6;Sawayn - Kovacek

View File

@ -0,0 +1,7 @@
Orc
North Anastacio
Will;Mage;18;24;21;3;25;17;4;21
Brennan;Mage;2;5;4;8;Lindgren, Spinka and Walsh
Jannie;Hunter;15;5;25;10;Kub - Flatley
Nicolette;Archer;11;9;3;17;16;10;18;15
Noe;Warrior;3;7;14;16;Bradtke, Deckow and Larson

View File

@ -0,0 +1,5 @@
Mage
Hunter
Warrior
Archer
Necromancer
1 Mage
2 Hunter
3 Warrior
4 Archer
5 Necromancer

View File

@ -0,0 +1,2 @@
Orc;North Anastacio;Brennan;Mage;2;5;4;8;Lindgren, Spinka and Walsh
Elf;Port Sierraton;Lyla;Archer;5;10;5;21;Crona - Abshire
1 Orc North Anastacio Brennan Mage 2 5 4 8 Lindgren, Spinka and Walsh
2 Elf Port Sierraton Lyla Archer 5 10 5 21 Crona - Abshire

View File

@ -0,0 +1,2 @@


Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LD_24\LD_24.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,42 @@
using System;
using Xunit;
using LD_24.Code;
using System.Collections.Generic;
using FluentAssertions;
namespace LD_24Tests
{
public class TaskUtilsTests
{
[Fact]
public void TestFindAllClasses()
{
List<Actor> actors = new List<Actor>();
actors.Add(new NPC("foo", "bar", "baz", "ClassAAA", 10, 10, 10, 10, "biz"));
actors.Add(new Hero("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, 10, 10, 10, 10));
actors.Add(new NPC("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, "baz"));
actors.Add(new Hero("foo", "bar", "baz", "ClassCCC", 10, 10, 10, 10, 10, 10, 10, 10));
List<string> classes = TaskUtils.FindAllClasses(actors);
classes.Should().BeEquivalentTo("ClassAAA", "ClassBBB", "ClassCCC");
}
[Fact]
public void TestFilterNPCsByAttack()
{
List<Actor> actors = new List<Actor>();
var actor1 = new NPC("foo", "bar", "baz", "ClassAAA", 10, 10, 9, 10, "biz");
var actor2 = new Hero("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, 10, 10, 10, 10);
var actor3 = new NPC("foo", "bar", "baz", "ClassBBB", 10, 10, 10, 10, "baz");
var actor4 = new Hero("foo", "bar", "baz", "ClassCCC", 10, 10, 10, 10, 10, 10, 10, 10);
var actor5 = new NPC("foo", "bar", "baz", "ClassBBB", 10, 10, 5, 10, "baz");
actors.Add(actor1);
actors.Add(actor2);
actors.Add(actor3);
actors.Add(actor4);
actors.Add(actor5);
var NPCs = TaskUtils.FilterNPCsByAttack(actors, 10);
NPCs.Should().BeEquivalentTo(new List<NPC> { actor1, actor5 });
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -81,6 +81,7 @@ didesnė kaip k eurų (n ir k įvedami klaviatūra).
[[sections]]
title = "Bendrinės klasės ir testavimas (L3)"
project = "L3/LD_24"
tests_project = "L3/LD_24Tests"
interface_scheme = "L3/LD_24/interface-scheme.png"
guide = """
* Atsidaryti tinklalapį
@ -88,6 +89,15 @@ guide = """
* Įvesti n ir k (n - minimalus vienetų kiekis, k - maksimali vieneto kaina)
* Spausti "Atrinkti" mygtuką
"""
lecturers_comment = """
Dictionary yra palikti kode, kad būtų galima leingviau grupuoti elementus pagal
kažkokį raktą.
"""
tests_screenshots = [
"L3/LD_24Tests/screenshot1.PNG",
"L3/LD_24Tests/screenshot2.PNG",
"L3/LD_24Tests/screenshot3.PNG"
]
problem = """
LD_24. Detalės.
@ -111,6 +121,50 @@ didesnė kaip k eurų (n ir k įvedami klaviatūra).
[[sections]]
title = "Polimorfizmas ir išimčių valdymas (L4)"
project = "L4/LD_24"
tests_project = "L4/LD_24Tests"
interface_scheme = "L4/LD_24/interface-scheme.png"
guide = """
* Atsidaryti tinklalapį
* Įvesti minimalus herojaus intelekto kiekį
* Įvesti maksimalus NPC žalos kiekį
* Spausti "Vykdyti" mygtuką
"""
tests_screenshots = [
"L4/LD_24Tests/screenshot1.png"
]
problem = """
U4_24. Kompiuterinis žaidimas.
Žaidimo pasaulyje yra dviejų tipų veikėjai - žaidėjo valdomi herojai bei
kompiuterio valdomi NPC (non playable character). Sugrupavote žaidimo veikėjus pagal rases, ir surašėte
jų duomenis į skirtingus failus. Duomenų formatas toks: pirmoje eilutėje rasės pavadinimas. Antroje
pradinis miestas. Toliau informacija apie žaidimo veikėjus. Sukurkite abstrakčią klasę Actor (savybės -
vardas, klasė, gyvybės taškai, mana, žalos taškai, gynybos taškai), kurią paveldės klasės Hero (savybės
jėga, vikrumas, intelektas, ypatinga galia), NPC (savybė gildija).
* Raskite kiekvienos klasės daugiausiai gyvybės taškų turintį veikėją, ekrane atspausdinkite jo vardą,
rasę, klasę ir gyvybės taškų kiekį.
* Sudarykite visų veikėjų klasių sąrašą ir įrašykite į failą Klasės.csv .
* Norite, jog kiekviena rasė turėtų bent po vieną kiekvienos klasės herojų ir NPC. Raskite, kokių
klasių herojų ar NPC trūksta kiekvienai rasei. Į failą Trūkstami.csv įrašykite kiekvienos rasės
pavadinimą, trūkstamų herojų klasių sąrašą, trūkstamų NPC klasių sąrašą.
* Sudarykite ir surikiuokite bendrą veikėjų rinktinę. Į šią rinktinę patenka herojai, jei jų intelekto
reikšmė viršija nurodytą dydį. Į šią rinktinę patenka NPC, jei jų žalos taškai neviršija nurodyto
dydžio. Herojus rikiuokite pagal intelektą, o NPC pagal žalos taškus. Rezultatus įrašykite į failą
Rinktine.csv.
"""
[[sections]]
title = "Deklaratyvusis programavimas (L5)"
problem = """
LDD_24. Leidėjai.
Žmonės užsisako spaudą. Užsakymas vyksta metų ribose. Pirmoje failo eilutėje
nurodyta įvedimo data (failų daug), o tolesnėse eilutėse nurodyta prenumeratoriaus pavardė, adresas,
laikotarpio pradžia (nurodyta sveiku skaičiumi 1..12), laikotarpio ilgis, leidinio kodas, leidinių kiekis.
Atskirame faile duota tokia informacija apie leidinius: kodas, pavadinimas, leidėjo pavadinimas, vieno
mėnesio kaina. Suskaičiuoti kiekvienam leidėjui nurodyto mėnesio (įvedama klaviatūra) pajamas.
Atspausdinkite leidėjų pajamas, surikiuotas pagal dydį ir leidėjų pavadinimus, nurodant ir leidėjų
leidinius su jų atneštomis pajamomis. Leidėjų pavadinimai neturi kartotis.
"""