Start Clicker oop
This commit is contained in:
parent
6361e14b88
commit
4d4146e197
16
Emne 3/ClickerOOP/ClickerOOP.sln
Normal file
16
Emne 3/ClickerOOP/ClickerOOP.sln
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClickerOOP", "ClickerOOP\ClickerOOP.csproj", "{C70D6421-5389-44D4-9ECF-E19B7A6BBAD7}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{C70D6421-5389-44D4-9ECF-E19B7A6BBAD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C70D6421-5389-44D4-9ECF-E19B7A6BBAD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C70D6421-5389-44D4-9ECF-E19B7A6BBAD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C70D6421-5389-44D4-9ECF-E19B7A6BBAD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
10
Emne 3/ClickerOOP/ClickerOOP/ClickerOOP.csproj
Normal file
10
Emne 3/ClickerOOP/ClickerOOP/ClickerOOP.csproj
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
3
Emne 3/ClickerOOP/ClickerOOP/Program.cs
Normal file
3
Emne 3/ClickerOOP/ClickerOOP/Program.cs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
|
Console.WriteLine("Hello, World!");
|
|
@ -2,14 +2,14 @@ namespace DIP.ChatServer;
|
||||||
|
|
||||||
public class ChatServer
|
public class ChatServer
|
||||||
{
|
{
|
||||||
private readonly List<ChatClient> _clients;
|
private readonly List<IChatClient> _clients;
|
||||||
|
|
||||||
public ChatServer()
|
public ChatServer()
|
||||||
{
|
{
|
||||||
_clients = new List<ChatClient>();
|
_clients = new List<IChatClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Broadcast(ChatClient client, string message)
|
public void Broadcast(IChatClient client, string message)
|
||||||
{
|
{
|
||||||
foreach (var chatClient in _clients)
|
foreach (var chatClient in _clients)
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ public class ChatServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Register(ChatClient client)
|
public void Register(IChatClient client)
|
||||||
{
|
{
|
||||||
_clients.Add(client);
|
_clients.Add(client);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace DIP.ChatServer;
|
||||||
|
|
||||||
|
public interface IChatClient
|
||||||
|
{
|
||||||
|
void Receive(string message);
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
namespace DependencyInversionPrinciple;
|
namespace DependencyInversionPrinciple;
|
||||||
|
using DIP.ChatServer;
|
||||||
|
|
||||||
public class ChatClient
|
public class ChatClient : IChatClient
|
||||||
{
|
{
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
private readonly ChatServer _server;
|
private readonly ChatServer _server;
|
||||||
|
|
Loading…
Reference in a new issue