Add project files.
This commit is contained in:
parent
b4f81c6013
commit
07d3c71778
25
oszto.sln
Normal file
25
oszto.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32106.194
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "oszto", "oszto\oszto.csproj", "{C1D33250-2D14-4016-AD6A-20AC6B3486BB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C1D33250-2D14-4016-AD6A-20AC6B3486BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C1D33250-2D14-4016-AD6A-20AC6B3486BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C1D33250-2D14-4016-AD6A-20AC6B3486BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C1D33250-2D14-4016-AD6A-20AC6B3486BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AA5B2685-B663-4E51-83B7-2FA98B543D95}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
74
oszto/Csomag.cs
Normal file
74
oszto/Csomag.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace oszto
|
||||
{
|
||||
class Csomag
|
||||
{
|
||||
public static readonly string[] fr_szinek = { "pikk", "kör", "káró", "treff" };
|
||||
public static readonly string[] fr_ertekek = { "2", "3", "4","5", "6", "7", "8", "9", "10", "J", "D", "K", "A" };
|
||||
public Kartyalap[] lapok;
|
||||
private int ennyivan;
|
||||
|
||||
public Csomag()
|
||||
{
|
||||
lapok = new Kartyalap[52];
|
||||
ennyivan = 52;
|
||||
int lit = 0;
|
||||
for (int i = 0; i < fr_szinek.Length; i++)
|
||||
{
|
||||
for (int j = 0; j < fr_ertekek.Length; j++)
|
||||
{
|
||||
lapok[lit] = new Kartyalap(fr_szinek[i], fr_ertekek[j]);
|
||||
lit++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void kever()
|
||||
{
|
||||
Random rd = new Random();
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
int n1 = rd.Next(0, 51);
|
||||
int n2 = rd.Next(0, 51);
|
||||
if (n1!=n2)
|
||||
{
|
||||
Kartyalap temp = lapok[n1];
|
||||
lapok[n1] = lapok[n2];
|
||||
lapok[n2] = temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
foreach (var item in lapok)
|
||||
{
|
||||
Console.WriteLine(item.szin + "-" + item.ertek);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//az osztás végrehajtása
|
||||
public Kartyalap[] huzas(int lapszam)
|
||||
{
|
||||
Kartyalap[] kt = new Kartyalap[lapszam];
|
||||
for (int i = 0; i < lapszam; i++)
|
||||
{
|
||||
kt[i] = lapok[ennyivan - (1 + i)];
|
||||
lapok[ennyivan - (1 + i)] = null;
|
||||
}
|
||||
ennyivan -= lapszam;
|
||||
return kt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
38
oszto/Jatekos.cs
Normal file
38
oszto/Jatekos.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace oszto
|
||||
{
|
||||
class Jatekos
|
||||
{
|
||||
public Kartyalap[] lapok;
|
||||
public string nev;
|
||||
private int ennyivan;
|
||||
|
||||
public Jatekos(string ujnev, int lapszam)
|
||||
{
|
||||
nev = ujnev;
|
||||
lapok = new Kartyalap[lapszam];
|
||||
ennyivan = 0;
|
||||
}
|
||||
|
||||
public void felvesz(Kartyalap[] osztas)
|
||||
{
|
||||
for (int i = 0; i < osztas.Length; i++)
|
||||
{
|
||||
lapok[ennyivan + i] = osztas[i];
|
||||
ennyivan += osztas.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public void terit()
|
||||
{
|
||||
Console.WriteLine("Nevem: {0}",nev);
|
||||
foreach (Kartyalap lap in lapok)
|
||||
{
|
||||
Console.Write(lap.szin + "-" + lap.ertek+" "+"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
oszto/Kartyalap.cs
Normal file
25
oszto/Kartyalap.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace oszto
|
||||
{
|
||||
class Kartyalap
|
||||
{
|
||||
public string szin;
|
||||
public string ertek;
|
||||
|
||||
public Kartyalap()
|
||||
{
|
||||
szin = "nincs";
|
||||
ertek = "nincs";
|
||||
}
|
||||
|
||||
public Kartyalap(String szin, String ertek)
|
||||
{
|
||||
this.szin = szin;
|
||||
this.ertek = ertek;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
71
oszto/Program.cs
Normal file
71
oszto/Program.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace oszto
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Csomag pakli = new Csomag();
|
||||
pakli.kever();
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Adja meg hány játékosnak osztok lapot");
|
||||
int jszam = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine("Adja meg hány lapot osztok egy játékosnak");
|
||||
int lszam = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine("Adja meg hányasával osszam a lapokat");
|
||||
int hszam = int.Parse(Console.ReadLine());
|
||||
|
||||
if (jszam*lszam>52)
|
||||
{
|
||||
throw new Exception("Nem elég nagy a paklid ahhoz, hogy kiossz ennyi lapot");
|
||||
}
|
||||
|
||||
if (lszam%hszam!=0)
|
||||
{
|
||||
throw new Exception("Nem lehet ennyiszer kiosztani a lapokat maradék nélkül");
|
||||
}
|
||||
|
||||
List<Jatekos> jatekosok = new List<Jatekos>();
|
||||
for (int i = 0; i < jszam; i++)
|
||||
{
|
||||
jatekosok.Add(new Jatekos("Játékos" + i,lszam));
|
||||
}
|
||||
|
||||
//osztás végrehajtása
|
||||
int kor = lszam / hszam;
|
||||
for (int i = 0; i < kor; i++)
|
||||
{
|
||||
for (int j = 0; j < jatekosok.Count; j++)
|
||||
{
|
||||
Kartyalap[] adag = pakli.huzas(hszam);
|
||||
jatekosok[j].felvesz(adag);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < jatekosok.Count; j++)
|
||||
{
|
||||
jatekosok[j].terit();
|
||||
|
||||
}
|
||||
|
||||
foreach (var item in pakli.lapok)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception hiba)
|
||||
{
|
||||
Console.WriteLine(hiba.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
8
oszto/oszto.csproj
Normal file
8
oszto/oszto.csproj
Normal file
|
@ -0,0 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user