diff --git a/.vs/ProjectEvaluation/lab1_pp.metadata.v9.bin b/.vs/ProjectEvaluation/lab1_pp.metadata.v9.bin new file mode 100644 index 0000000..8c2f73a Binary files /dev/null and b/.vs/ProjectEvaluation/lab1_pp.metadata.v9.bin differ diff --git a/.vs/ProjectEvaluation/lab1_pp.projects.v9.bin b/.vs/ProjectEvaluation/lab1_pp.projects.v9.bin new file mode 100644 index 0000000..d47812e Binary files /dev/null and b/.vs/ProjectEvaluation/lab1_pp.projects.v9.bin differ diff --git a/.vs/ProjectEvaluation/lab1_pp.strings.v9.bin b/.vs/ProjectEvaluation/lab1_pp.strings.v9.bin new file mode 100644 index 0000000..5782d95 Binary files /dev/null and b/.vs/ProjectEvaluation/lab1_pp.strings.v9.bin differ diff --git a/.vs/lab1_PP/DesignTimeBuild/.dtbcache.v2 b/.vs/lab1_PP/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..90851fe Binary files /dev/null and b/.vs/lab1_PP/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/lab1_PP/FileContentIndex/b491fe4f-5414-4c7b-9628-ac1f9c08090f.vsidx b/.vs/lab1_PP/FileContentIndex/b491fe4f-5414-4c7b-9628-ac1f9c08090f.vsidx new file mode 100644 index 0000000..892914b Binary files /dev/null and b/.vs/lab1_PP/FileContentIndex/b491fe4f-5414-4c7b-9628-ac1f9c08090f.vsidx differ diff --git a/.vs/lab1_PP/FileContentIndex/e915651b-7e71-4e75-baa6-9b5500ab05de.vsidx b/.vs/lab1_PP/FileContentIndex/e915651b-7e71-4e75-baa6-9b5500ab05de.vsidx new file mode 100644 index 0000000..a231874 Binary files /dev/null and b/.vs/lab1_PP/FileContentIndex/e915651b-7e71-4e75-baa6-9b5500ab05de.vsidx differ diff --git a/.vs/lab1_PP/v17/.futdcache.v2 b/.vs/lab1_PP/v17/.futdcache.v2 new file mode 100644 index 0000000..8c7e5ba Binary files /dev/null and b/.vs/lab1_PP/v17/.futdcache.v2 differ diff --git a/.vs/lab1_PP/v17/.suo b/.vs/lab1_PP/v17/.suo new file mode 100644 index 0000000..fa2355c Binary files /dev/null and b/.vs/lab1_PP/v17/.suo differ diff --git a/.vs/lab1_PP/v17/DocumentLayout.backup.json b/.vs/lab1_PP/v17/DocumentLayout.backup.json new file mode 100644 index 0000000..6a1c4be --- /dev/null +++ b/.vs/lab1_PP/v17/DocumentLayout.backup.json @@ -0,0 +1,54 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|c:\\users\\student.desktop-n01b4au\\desktop\\pp\\lab1_pp\\lab1_pp\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|solutionrelative:lab1_pp\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|c:\\users\\student.desktop-n01b4au\\desktop\\pp\\lab1_pp\\lab1_pp\\highscore.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|solutionrelative:lab1_pp\\highscore.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 1, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "HighScore.cs", + "DocumentMoniker": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\HighScore.cs", + "RelativeDocumentMoniker": "lab1_PP\\HighScore.cs", + "ToolTip": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\HighScore.cs", + "RelativeToolTip": "lab1_PP\\HighScore.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-10-10T14:37:28.479Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "Program.cs", + "DocumentMoniker": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\Program.cs", + "RelativeDocumentMoniker": "lab1_PP\\Program.cs", + "ToolTip": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\Program.cs", + "RelativeToolTip": "lab1_PP\\Program.cs", + "ViewState": "AgIAACoAAAAAAAAAAAAAAEAAAAA8AAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-10-10T14:03:27.833Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/.vs/lab1_PP/v17/DocumentLayout.json b/.vs/lab1_PP/v17/DocumentLayout.json new file mode 100644 index 0000000..6a1c4be --- /dev/null +++ b/.vs/lab1_PP/v17/DocumentLayout.json @@ -0,0 +1,54 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|c:\\users\\student.desktop-n01b4au\\desktop\\pp\\lab1_pp\\lab1_pp\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|solutionrelative:lab1_pp\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|c:\\users\\student.desktop-n01b4au\\desktop\\pp\\lab1_pp\\lab1_pp\\highscore.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{F9463B85-2F8C-4E78-8131-04D0E9914962}|lab1_PP\\lab1_PP.csproj|solutionrelative:lab1_pp\\highscore.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 1, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "HighScore.cs", + "DocumentMoniker": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\HighScore.cs", + "RelativeDocumentMoniker": "lab1_PP\\HighScore.cs", + "ToolTip": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\HighScore.cs", + "RelativeToolTip": "lab1_PP\\HighScore.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-10-10T14:37:28.479Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "Program.cs", + "DocumentMoniker": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\Program.cs", + "RelativeDocumentMoniker": "lab1_PP\\Program.cs", + "ToolTip": "C:\\Users\\student.DESKTOP-N01B4AU\\Desktop\\PP\\lab1_PP\\lab1_PP\\Program.cs", + "RelativeToolTip": "lab1_PP\\Program.cs", + "ViewState": "AgIAACoAAAAAAAAAAAAAAEAAAAA8AAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-10-10T14:03:27.833Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/lab1_PP.sln b/lab1_PP.sln new file mode 100644 index 0000000..d04ed84 --- /dev/null +++ b/lab1_PP.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35312.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab1_PP", "lab1_PP\lab1_PP.csproj", "{F9463B85-2F8C-4E78-8131-04D0E9914962}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F9463B85-2F8C-4E78-8131-04D0E9914962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9463B85-2F8C-4E78-8131-04D0E9914962}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9463B85-2F8C-4E78-8131-04D0E9914962}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9463B85-2F8C-4E78-8131-04D0E9914962}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {86C4EC80-575C-433B-96A1-97EF9F3683D3} + EndGlobalSection +EndGlobal diff --git a/lab1_PP/HighScore.cs b/lab1_PP/HighScore.cs new file mode 100644 index 0000000..5e0f482 --- /dev/null +++ b/lab1_PP/HighScore.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace lab1_PP +{ + internal class HighScore + { + public string Name { get; set; } + public int Trials { get; set; } + + } +} diff --git a/lab1_PP/Program.cs b/lab1_PP/Program.cs new file mode 100644 index 0000000..49524fb --- /dev/null +++ b/lab1_PP/Program.cs @@ -0,0 +1,66 @@ +//zadanie 1.3. +using lab1_PP; +using System.Text.Json; +using System.Xml.Linq; + +Console.WriteLine("zadanie 1.3."); +for (int i = 1; i <= 100; i++) +{ + if(i%3==0 && i % 5 == 0) { Console.WriteLine("FizzBuzz"); } + else if(i%3==0) { Console.WriteLine("Fizz"); } + else if(i%5==0) { Console.WriteLine("Buzz"); } + else { Console.WriteLine(i); } +} + +//zadanie 1.3. +Console.WriteLine("zadanie 1.3."); +var rand = new Random(); +var value = rand.Next(1, 101); +int guess = 0; +bool validInput = false; +int trials = 0; +while (guess != value) +{ + Console.WriteLine("Wprowadź wartość: "); + validInput = int.TryParse(Console.ReadLine(), out guess); + if (!validInput) + { + Console.WriteLine("To nie jest poprawna liczba. Spróbuj ponownie."); + continue; + } + + if (guess > value) + { + trials++; + Console.WriteLine("Za dużo"); + } + else if (guess < value) + { + trials++; + Console.WriteLine("Za mało"); + } +} +trials++; +Console.WriteLine("Wygrana w "+trials+" probie!"); +string name; +do +{ + Console.WriteLine("Podaj swoje imię:"); + name = Console.ReadLine(); +} while (string.IsNullOrWhiteSpace(name)); + +//zapisanie do listy i utworzenie pliku jesli nie istnieje +List highScores; +const string FileName = "highscores.json"; +if (File.Exists(FileName)) + highScores = JsonSerializer.Deserialize>(File.ReadAllText(FileName)); +else + highScores = new List(); + +var hs = new HighScore { Name = name, Trials = trials }; +highScores.Add(hs); +File.WriteAllText(FileName,JsonSerializer.Serialize(highScores)); +foreach (var item in highScores.OrderBy(h => h.Trials)) +{ + Console.WriteLine($"{item.Name} -- {item.Trials} prób"); +} \ No newline at end of file diff --git a/lab1_PP/lab1_PP.csproj b/lab1_PP/lab1_PP.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/lab1_PP/lab1_PP.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + +