This commit is contained in:
Rens Pastoor
2025-05-27 22:41:46 +02:00
parent d141296aea
commit 11b391b8a1
416 changed files with 25232 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/.idea.Starter_assignment.iml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

Binary file not shown.

View File

@@ -0,0 +1,74 @@
namespace Starter_assignment;
class Course {
private List<Student> students = new List<Student>();
private Dictionary<string, List<Student>> groups = new Dictionary<string, List<Student>>();
private int groupCounter = 1;
public void AddStudent(string name, int studentNumber) {
name = name.Trim();
foreach (Student student in students) {
if (student.GetStudentNumber() == studentNumber) {
Console.WriteLine("Student number must be unique.");
return;
}
}
string groupName = groups.Keys.LastOrDefault();
if (groupName == null || groups[groupName].Count >= 3) {
groupName = $"PG{groupCounter}";
groups[groupName] = new List<Student>();
groupCounter++;
}
Student newStudent = new Student(name, studentNumber, groupName);
students.Add(newStudent);
groups[groupName].Add(newStudent);
Console.WriteLine($"Student {name} added successfully to {groupName}.");
}
public void ViewAllStudents() {
foreach (Student student in students) {
Console.WriteLine(student.GetInfo());
}
}
public void ViewAllGroups() {
foreach (KeyValuePair<string, List<Student>> group in groups) {
Console.WriteLine(group.Key);
}
}
public void SearchByStudentNumber(int studentNumber) {
Student foundStudent = null;
foreach (Student student in students) {
int currentStudentNumber = student.GetStudentNumber();
if (currentStudentNumber == studentNumber) {
foundStudent = student;
break;
}
}
if (foundStudent != null) {
Console.WriteLine(foundStudent.GetInfo());
} else {
Console.WriteLine("No student found.");
}
}
public void SearchByGroup(string groupName) {
if (groups.ContainsKey(groupName)) {
foreach (Student student in groups[groupName]) {
Console.WriteLine(student.GetInfo());
}
} else {
Console.WriteLine("Group not found.");
}
}
public void ShowStatistics() {
Console.WriteLine($"Total students: {students.Count}");
Console.WriteLine($"Total groups: {groups.Count}");
}
}

View File

@@ -0,0 +1,62 @@
namespace Starter_assignment;
class Program {
static void Main() {
Course course = new Course();
bool running = true;
while (running) {
Console.WriteLine("\n1. Add Student" +
"\n2. View All Students" +
"\n3. View All Groups" +
"\n4. Search Student by Number" +
"\n5. Show Students in a Group" +
"\n6. Show Statistics" +
"\n7. Exit" +
"\nChoose an option: ");
string choice = Console.ReadLine();
switch (choice)
{
case "1":
Console.Write("Enter student name: ");
string name = Console.ReadLine();
Console.Write("Enter student number: ");
if (int.TryParse(Console.ReadLine(), out int studentNumber)) {
course.AddStudent(name, studentNumber);
} else {
Console.WriteLine("Invalid student number.");
}
break;
case "2":
course.ViewAllStudents();
break;
case "3":
course.ViewAllGroups();
break;
case "4":
Console.Write("Enter student number: ");
if (int.TryParse(Console.ReadLine(), out int searchNumber)) {
course.SearchByStudentNumber(searchNumber);
}
break;
case "5":
Console.Write("Enter group name: ");
string groupName = Console.ReadLine();
course.SearchByGroup(groupName);
break;
case "6":
course.ShowStatistics();
break;
case "7":
running = false;
break;
default:
Console.WriteLine("Invalid option, try again.");
break;
}
}
}
}

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>

Binary file not shown.

View File

@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Starter_assignment", "Starter_assignment\Starter_assignment.csproj", "{C78EC255-456E-4C45-912E-49607AD28EDC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C78EC255-456E-4C45-912E-49607AD28EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C78EC255-456E-4C45-912E-49607AD28EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C78EC255-456E-4C45-912E-49607AD28EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C78EC255-456E-4C45-912E-49607AD28EDC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AConsole_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2ccd2056ec55b7b67558d52e32a887ed5ac7e346fc429b218c188d0a99cb5be_003FConsole_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATextReader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F5b34e2245c26def5c9df2f8c13df6c04246252f96a7cebf7db554fed90435_003FTextReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/ActualSeverity/@EntryValue">ERROR</s:String></wpf:ResourceDictionary>

View File

@@ -0,0 +1,73 @@
namespace Starter_assignment;
class Course {
private List<Student> students = new List<Student>();
private Dictionary<string, List<Student>> groups = new Dictionary<string, List<Student>>();
private int groupCounter = 1;
public void AddStudent(string name, int studentNumber) {
name = name.Trim();
foreach (Student student in students) {
if (student.GetStudentNumber() == studentNumber) {
Console.WriteLine("Student number must be unique.");
return;
}
}
string groupName = groups.Keys.LastOrDefault();
if (groupName == null || groups[groupName].Count >= 3) {
groupName = $"PG{groupCounter}";
groups[groupName] = new List<Student>();
groupCounter++;
}
Student newStudent = new Student(name, studentNumber, groupName);
students.Add(newStudent);
groups[groupName].Add(newStudent);
Console.WriteLine($"Student {name} added successfully to {groupName}.");
}
public void ViewAllStudents() {
foreach (Student student in students) {
Console.WriteLine(student.GetInfo());
}
}
public void ViewAllGroups() {
foreach (KeyValuePair<string, List<Student>> group in groups) {
Console.WriteLine(group.Key);
}
}
public void SearchByStudentNumber(int studentNumber) {
Student foundStudent = null;
foreach (Student student in students) {
int currentStudentNumber = student.GetStudentNumber();
if (currentStudentNumber == studentNumber) {
foundStudent = student;
break;
}
}
if (foundStudent != null) {
Console.WriteLine(foundStudent.GetInfo());
} else {
Console.WriteLine("No student found.");
}
}
public void SearchByGroup(string groupName) {
if (groups.ContainsKey(groupName)) {
foreach (Student student in groups[groupName]) {
Console.WriteLine(student.GetInfo());
}
} else {
Console.WriteLine("Group not found.");
}
}
public void ShowStatistics() {
Console.WriteLine($"Total students: {students.Count}");
Console.WriteLine($"Total groups: {groups.Count}");
}
}

View File

@@ -0,0 +1,62 @@
namespace Starter_assignment;
class Program {
static void Main() {
Course course = new Course();
bool running = true;
while (running) {
Console.WriteLine("\n1. Add Student" +
"\n2. View All Students" +
"\n3. View All Groups" +
"\n4. Search Student by Number" +
"\n5. Show Students in a Group" +
"\n6. Show Statistics" +
"\n7. Exit" +
"\nChoose an option: ");
string choice = Console.ReadLine();
switch (choice)
{
case "1":
Console.Write("Enter student name: ");
string name = Console.ReadLine();
Console.Write("Enter student number: ");
if (int.TryParse(Console.ReadLine(), out int studentNumber)) {
course.AddStudent(name, studentNumber);
} else {
Console.WriteLine("Invalid student number.");
}
break;
case "2":
course.ViewAllStudents();
break;
case "3":
course.ViewAllGroups();
break;
case "4":
Console.Write("Enter student number: ");
if (int.TryParse(Console.ReadLine(), out int searchNumber)) {
course.SearchByStudentNumber(searchNumber);
}
break;
case "5":
Console.Write("Enter group name: ");
string groupName = Console.ReadLine();
course.SearchByGroup(groupName);
break;
case "6":
course.ShowStatistics();
break;
case "7":
running = false;
break;
default:
Console.WriteLine("Invalid option, try again.");
break;
}
}
}
}

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,27 @@
namespace Starter_assignment;
class Student {
private string Name { get; }
private int StudentNumber { get; }
private string GroupName { get; }
public Student(string name, int studentNumber, string groupName) {
if (string.IsNullOrWhiteSpace(name)) {
throw new ArgumentException("Name cannot be empty.");
}
if (studentNumber < 10000 && studentNumber != -1) {
throw new ArgumentException("Student number must be >= 10000 or -1.");
}
Name = name;
StudentNumber = studentNumber;
GroupName = groupName;
}
public int GetStudentNumber() {
return StudentNumber;
}
public string GetInfo() {
return $"{Name} ({StudentNumber}) - {GroupName}";
}
}

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Starter_assignment/1.0.0": {
"runtime": {
"Starter_assignment.dll": {}
}
}
}
},
"libraries": {
"Starter_assignment/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Starter_assignment")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Starter_assignment")]
[assembly: System.Reflection.AssemblyTitleAttribute("Starter_assignment")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
77da79aa1d8b67801697281643b61dd3f4e48c0c7f245ecd395dee391118be92

View File

@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Starter_assignment
build_property.ProjectDir = /home/rens/T2/CS/Starter_assignment/Starter_assignment/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
63f646a6f5c36f8a67f54301cd756f80709a6758f27e90e85bd3caa85964b27d

View File

@@ -0,0 +1,10 @@
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/bin/Debug/net8.0/Starter_assignment
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/bin/Debug/net8.0/Starter_assignment.dll
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/bin/Debug/net8.0/Starter_assignment.pdb
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/Starter_assignment.GeneratedMSBuildEditorConfig.editorconfig
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/Starter_assignment.AssemblyInfoInputs.cache
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/Starter_assignment.AssemblyInfo.cs
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/Starter_assignment.csproj.CoreCompileInputs.cache
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/Starter_assignment.dll
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/refint/Starter_assignment.dll
/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/Debug/net8.0/Starter_assignment.pdb

View File

@@ -0,0 +1 @@
4028af397b722be4e5490a9f64106d4a5c363b00c8703dae917b145b5632baa4

View File

@@ -0,0 +1,66 @@
{
"format": 1,
"restore": {
"/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj": {}
},
"projects": {
"/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
"projectName": "Starter_assignment",
"projectPath": "/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
"packagesPath": "/home/rens/.nuget/packages/",
"outputPath": "/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/rens/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/home/rens/.dotnet/sdk/8.0.404/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/rens/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/rens/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/rens/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,71 @@
{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"/home/rens/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
"projectName": "Starter_assignment",
"projectPath": "/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
"packagesPath": "/home/rens/.nuget/packages/",
"outputPath": "/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/rens/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/home/rens/.dotnet/sdk/8.0.404/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "0d5jt8ngUw0=",
"success": true,
"projectFilePath": "/home/rens/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
"expectedPackageFiles": [],
"logs": []
}

View File

@@ -0,0 +1 @@
"restore":{"projectUniqueName":"/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj","projectName":"Starter_assignment","projectPath":"/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj","outputPath":"/home/rens/files/T2/CS/Starter_assignment/Starter_assignment/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net8.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net8.0":{"targetAlias":"net8.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]},"restoreAuditProperties":{"enableAudit":"true","auditLevel":"low","auditMode":"direct"}}"frameworks":{"net8.0":{"targetAlias":"net8.0","imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/home/rens/.dotnet/sdk/8.0.404/PortableRuntimeIdentifierGraph.json"}}

View File

@@ -0,0 +1 @@
17406469005085962

View File

@@ -0,0 +1 @@
17406469005085962

View File

@@ -0,0 +1,27 @@
namespace Starter_assignment;
class Student {
private string Name { get; }
private int StudentNumber { get; }
private string GroupName { get; }
public Student(string name, int studentNumber, string groupName) {
if (string.IsNullOrWhiteSpace(name)) {
throw new ArgumentException("Name cannot be empty.");
}
if (studentNumber < 10000 && studentNumber != -1) {
throw new ArgumentException("Student number must be >= 10000 or -1.");
}
Name = name;
StudentNumber = studentNumber;
GroupName = groupName;
}
public int GetStudentNumber() {
return StudentNumber;
}
public string GetInfo() {
return $"{Name} ({StudentNumber}) - {GroupName}";
}
}

Binary file not shown.