Start Clicker oop

This commit is contained in:
Geir Okkenhaug Jerstad 2025-01-08 10:32:47 +01:00
parent 6361e14b88
commit 4d4146e197
6 changed files with 41 additions and 5 deletions

View 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

View 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>

View file

@ -0,0 +1,3 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

View file

@ -2,14 +2,14 @@ namespace DIP.ChatServer;
public class ChatServer
{
private readonly List<ChatClient> _clients;
private readonly List<IChatClient> _clients;
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)
{
@ -21,7 +21,7 @@ public class ChatServer
}
}
public void Register(ChatClient client)
public void Register(IChatClient client)
{
_clients.Add(client);
}

View file

@ -0,0 +1,6 @@
namespace DIP.ChatServer;
public interface IChatClient
{
void Receive(string message);
}

View file

@ -1,6 +1,7 @@
namespace DependencyInversionPrinciple;
using DIP.ChatServer;
public class ChatClient
public class ChatClient : IChatClient
{
private readonly string _name;
private readonly ChatServer _server;