Skip to content

Commit 5a510ab

Browse files
author
Lorenzo Ruggeri
committed
First Commit
1 parent d7d1937 commit 5a510ab

18 files changed

+662
-0
lines changed

.editorconfig

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\AKKA-Workspace\Repos\Akka-TechCompetition-2021 codebase based on best match to current usage at 26-Mar-21
2+
# You can modify the rules from these initially generated values to suit your own policies
3+
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
4+
[*.cs]
5+
6+
7+
#Core editorconfig formatting - indentation
8+
9+
# Indentation and spacing
10+
indent_style = space
11+
indent_size = 2
12+
13+
#Formatting - new line options
14+
csharp_new_line_before_open_brace = all
15+
#place else statements on a new line
16+
csharp_new_line_before_else = true
17+
#require members of anonymous types to be on the same line
18+
csharp_new_line_before_members_in_anonymous_types = true
19+
#require members of object intializers to be on separate lines
20+
csharp_new_line_before_members_in_object_initializers = true
21+
#require braces to be on a new line for methods, control_blocks, and types (also known as "Allman" style)
22+
csharp_new_line_before_open_brace = all
23+
24+
#Formatting - organize using options
25+
26+
#sort System.* using directives alphabetically, and place them before other usings
27+
dotnet_sort_system_directives_first = true
28+
29+
#Formatting - spacing options
30+
31+
#require NO space between a cast and the value
32+
csharp_space_after_cast = false
33+
#require a space before the colon for bases or interfaces in a type declaration
34+
csharp_space_after_colon_in_inheritance_clause = true
35+
#require a space after a keyword in a control flow statement such as a for loop
36+
csharp_space_after_keywords_in_control_flow_statements = true
37+
#require a space before the colon for bases or interfaces in a type declaration
38+
csharp_space_before_colon_in_inheritance_clause = true
39+
#remove space within empty argument list parentheses
40+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
41+
#remove space between method call name and opening parenthesis
42+
csharp_space_between_method_call_name_and_opening_parenthesis = false
43+
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
44+
csharp_space_between_method_call_parameter_list_parentheses = false
45+
#remove space within empty parameter list parentheses for a method declaration
46+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
47+
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
48+
csharp_space_between_method_declaration_parameter_list_parentheses = false
49+
50+
#Formatting - wrapping options
51+
52+
#leave code block on single line
53+
csharp_preserve_single_line_blocks = true
54+
55+
#Style - Code block preferences
56+
57+
#prefer curly braces even for one line of code
58+
csharp_prefer_braces = true:suggestion
59+
60+
#Style - expression bodied member options
61+
62+
#prefer block bodies for constructors
63+
csharp_style_expression_bodied_constructors = false:suggestion
64+
#prefer block bodies for methods
65+
csharp_style_expression_bodied_methods = false:suggestion
66+
67+
#Style - expression level options
68+
69+
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
70+
dotnet_style_predefined_type_for_member_access = true:suggestion
71+
72+
#Style - Expression-level preferences
73+
74+
#prefer objects to be initialized using object initializers when possible
75+
dotnet_style_object_initializer = true:suggestion
76+
#prefer inferred anonymous type member names
77+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
78+
79+
#Style - implicit and explicit types
80+
81+
#prefer var over explicit type in all cases, unless overridden by another code style rule
82+
csharp_style_var_elsewhere = true:suggestion
83+
#prefer explicit type over var to declare variables with built-in system types such as int
84+
csharp_style_var_for_built_in_types = false:suggestion
85+
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
86+
csharp_style_var_when_type_is_apparent = true:suggestion
87+
88+
#Style - language keyword and framework type options
89+
90+
#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
91+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
92+
93+
#Style - modifier options
94+
95+
#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
96+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
97+
98+
#Style - Modifier preferences
99+
100+
#when this rule is set to a list of modifiers, prefer the specified ordering.
101+
csharp_preferred_modifier_order = public,private,protected,static,readonly,override:suggestion
102+
103+
# IDE0003: Remove qualification
104+
dotnet_diagnostic.IDE0003.severity = none

Akka-CodingChallenge-2021.sln

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30204.135
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Main", "Akka.Main\Akka.Main.csproj", "{98E2335A-408F-4DD9-8FE5-5672C534D490}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D76CABF6-F927-4639-9AD2-1B53A374A53D}"
9+
ProjectSection(SolutionItems) = preProject
10+
.editorconfig = .editorconfig
11+
README.docx = README.docx
12+
EndProjectSection
13+
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Core", "Akka.Core\Akka.Core.csproj", "{78DD143A-B143-479F-880C-9993129110D0}"
15+
EndProject
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Models", "Akka.Models\Akka.Models.csproj", "{68BD5187-6294-42C5-9D9B-D0EA48ACCAC0}"
17+
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Main.Tests", "Akka.Main.Tests\Akka.Main.Tests.csproj", "{729EAE02-C34A-4612-AEEE-7F7DC6D7A21A}"
19+
EndProject
20+
Global
21+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
22+
Debug|Any CPU = Debug|Any CPU
23+
Release|Any CPU = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{98E2335A-408F-4DD9-8FE5-5672C534D490}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{98E2335A-408F-4DD9-8FE5-5672C534D490}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{98E2335A-408F-4DD9-8FE5-5672C534D490}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{98E2335A-408F-4DD9-8FE5-5672C534D490}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{78DD143A-B143-479F-880C-9993129110D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{78DD143A-B143-479F-880C-9993129110D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{78DD143A-B143-479F-880C-9993129110D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{78DD143A-B143-479F-880C-9993129110D0}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{68BD5187-6294-42C5-9D9B-D0EA48ACCAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{68BD5187-6294-42C5-9D9B-D0EA48ACCAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{68BD5187-6294-42C5-9D9B-D0EA48ACCAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{68BD5187-6294-42C5-9D9B-D0EA48ACCAC0}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{729EAE02-C34A-4612-AEEE-7F7DC6D7A21A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{729EAE02-C34A-4612-AEEE-7F7DC6D7A21A}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{729EAE02-C34A-4612-AEEE-7F7DC6D7A21A}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{729EAE02-C34A-4612-AEEE-7F7DC6D7A21A}.Release|Any CPU.Build.0 = Release|Any CPU
42+
EndGlobalSection
43+
GlobalSection(SolutionProperties) = preSolution
44+
HideSolutionNode = FALSE
45+
EndGlobalSection
46+
GlobalSection(ExtensibilityGlobals) = postSolution
47+
SolutionGuid = {3E63027A-629D-4766-BB1D-E2C83E9628D2}
48+
EndGlobalSection
49+
EndGlobal

Akka.Core/Akka.Core.csproj

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<AssemblyName>Akka.Core</AssemblyName>
6+
<RootNamespace>Akka.Core</RootNamespace>
7+
</PropertyGroup>
8+
9+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Akka.Core.Models;
5+
6+
namespace Akka.Core.Components
7+
{
8+
public abstract class AbstractTileProcessor : ITileProcessor
9+
{
10+
private IScreenResolution resolution;
11+
12+
public int ScreenWidth
13+
{
14+
get { return resolution?.Width ?? throw new ArgumentNullException(nameof(ScreenWidth)); }
15+
}
16+
17+
public int ScreenHeight
18+
{
19+
get { return resolution?.Height ?? throw new ArgumentNullException(nameof(ScreenHeight)); }
20+
}
21+
22+
public abstract string TeamName { get; }
23+
24+
public void SetScreenResolution(IScreenResolution resolution)
25+
{
26+
if (resolution == null)
27+
throw new ArgumentNullException(nameof(resolution));
28+
if (resolution.Width == default)
29+
throw new ArgumentException(nameof(resolution.Width));
30+
if (resolution.Height == default)
31+
throw new ArgumentException(nameof(resolution.Height));
32+
33+
this.resolution = resolution;
34+
}
35+
36+
public abstract void Calculate(IEnumerable<IWindow> input);
37+
}
38+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Collections.Generic;
2+
using Akka.Core.Models;
3+
4+
namespace Akka.Core.Components
5+
{
6+
public interface ITileProcessor
7+
{
8+
/// <summary>
9+
/// La larghezza del desktop sul quale si andrà ad operare.
10+
/// </summary>
11+
int ScreenWidth { get; }
12+
13+
/// <summary>
14+
/// L'altezza del desktop sul quale si andrà ad operare.
15+
/// </summary>
16+
int ScreenHeight { get; }
17+
18+
/// <summary>
19+
/// Il nome del Team impegnato nella Code-Challenge.
20+
/// </summary>
21+
string TeamName { get; }
22+
23+
/// <summary>
24+
/// Processa una lista (<paramref name="input"/>) di <see cref="IWindow"/> per
25+
/// ottenere un tiling in base alla risoluzione dello schermo.
26+
/// </summary>
27+
/// <param name="input"></param>
28+
/// <returns></returns>
29+
void Calculate(IEnumerable<IWindow> input);
30+
31+
/// <summary>
32+
/// Imposta la risoluzione dello schermo.
33+
/// </summary>
34+
/// <param name="resolution"></param>
35+
void SetScreenResolution(IScreenResolution resolution);
36+
}
37+
}

Akka.Core/Models/IScreenResolution.cs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Akka.Core.Models
2+
{
3+
public interface IScreenResolution
4+
{
5+
int Width { get; }
6+
int Height { get; }
7+
}
8+
}

Akka.Core/Models/IWindow.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Akka.Core.Models
2+
{
3+
public interface IWindow
4+
{
5+
int ID { get; }
6+
int Width { get; set; }
7+
int Height { get; set; }
8+
int X { get; set; }
9+
int Y { get; set; }
10+
int MinWidth { get; }
11+
int MinHeight { get; }
12+
}
13+
}

Akka.Core/Models/ModelsExtensions.cs

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Akka.Core.Models
6+
{
7+
public static class ModelsExtensions
8+
{
9+
/// <summary>
10+
/// Determina se interseca con <paramref name="window"/>.
11+
/// </summary>
12+
/// <param name="self"></param>
13+
/// <param name="window"></param>
14+
/// <returns>
15+
/// <see langword="true"/> se la finestra interseca.
16+
/// </returns>
17+
public static bool IntersectsWith(this IWindow self, IWindow window)
18+
{
19+
return (window.X < self.X + self.Width) &&
20+
(self.X < (window.X + window.Width)) &&
21+
(window.Y < self.Y + self.Height) &&
22+
(self.Y < window.Y + window.Height);
23+
}
24+
25+
/// <summary>
26+
/// Restringe l'area della finestra ai requisiti minimi imposti dalle
27+
/// proprietà <see cref="IWindow.MinWidth"/> e <see cref="IWindow.MinHeight"/>.
28+
/// </summary>
29+
/// <param name="self"></param>
30+
public static void Shrink(this IWindow self)
31+
{
32+
self.Width = self.MinWidth;
33+
self.Height = self.MinHeight;
34+
}
35+
36+
/// <summary>
37+
/// Calcola l'area della finestra.
38+
/// </summary>
39+
/// <param name="self"></param>
40+
/// <returns></returns>
41+
public static int Area(this IWindow self)
42+
{
43+
return self.Width * self.Height;
44+
}
45+
46+
public static int Right(this IWindow self)
47+
{
48+
return unchecked(self.X + self.Width);
49+
}
50+
51+
public static int Bottom(this IWindow self)
52+
{
53+
return unchecked(self.Y + self.Height);
54+
}
55+
}
56+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="NUnit" Version="3.12.0" />
11+
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\Akka.Models\Akka.Models.csproj" />
17+
<ProjectReference Include="..\Akka.Main\Akka.Main.csproj" />
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)