C/ fix
This commit is contained in:
Binary file not shown.
Binary file not shown.
13
C/CS/Starter_assignment/.idea/.idea.Starter_assignment/.idea/.gitignore
generated
vendored
13
C/CS/Starter_assignment/.idea/.idea.Starter_assignment/.idea/.gitignore
generated
vendored
@@ -1,13 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
|
||||||
</project>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="UserContentModel">
|
|
||||||
<attachedFolders />
|
|
||||||
<explicitIncludes />
|
|
||||||
<explicitExcludes />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Binary file not shown.
@@ -1,74 +0,0 @@
|
|||||||
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}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<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.
@@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
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
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
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}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"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": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"runtimeOptions": {
|
|
||||||
"tfm": "net8.0",
|
|
||||||
"framework": {
|
|
||||||
"name": "Microsoft.NETCore.App",
|
|
||||||
"version": "8.0.0"
|
|
||||||
},
|
|
||||||
"configProperties": {
|
|
||||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
// <autogenerated />
|
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <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.
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
77da79aa1d8b67801697281643b61dd3f4e48c0c7f245ecd395dee391118be92
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
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 =
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// <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;
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
63f646a6f5c36f8a67f54301cd756f80709a6758f27e90e85bd3caa85964b27d
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/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
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
4028af397b722be4e5490a9f64106d4a5c363b00c8703dae917b145b5632baa4
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"dgSpecHash": "0d5jt8ngUw0=",
|
|
||||||
"success": true,
|
|
||||||
"projectFilePath": "/home/rens/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
|
|
||||||
"expectedPackageFiles": [],
|
|
||||||
"logs": []
|
|
||||||
}
|
|
||||||
@@ -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","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"}}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
17406469005085962
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
17406469005085962
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.
Binary file not shown.
@@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
],
|
|
||||||
"unwantedRecommendations": [
|
|
||||||
"ms-vscode.cpptools-extension-pack"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#ifndef SERIALPROCESS_H
|
|
||||||
#define SERIALPROCESS_H
|
|
||||||
|
|
||||||
class SerialProcess {
|
|
||||||
private:
|
|
||||||
uint8_t ndx; // Current index for the buffer
|
|
||||||
const char beginMarker = '#'; // Marker to indicate the start of a message
|
|
||||||
const char endMarker = ';'; // Marker to indicate the end of a message
|
|
||||||
char rc; // Character read from Serial
|
|
||||||
int address; // Device address
|
|
||||||
bool newData; // Flag for new data availability
|
|
||||||
static const uint8_t numChars = 255; // Maximum size of the buffer
|
|
||||||
char receivedChars[numChars]; // Buffer for incoming data
|
|
||||||
bool rcCheck;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
explicit SerialProcess(int addr);
|
|
||||||
|
|
||||||
// Store Serial Input (if available)
|
|
||||||
void SerialInput();
|
|
||||||
|
|
||||||
// Check if new data is available
|
|
||||||
bool isNewDataAvailable();
|
|
||||||
|
|
||||||
// Get the received data
|
|
||||||
char* getReceivedData();
|
|
||||||
|
|
||||||
// Process the received message
|
|
||||||
void getPayload(char* payload);
|
|
||||||
|
|
||||||
// Send message in the correct format
|
|
||||||
void sendMessage(int receiver, const char* payload);
|
|
||||||
|
|
||||||
void changeAddress(int addr);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SERIALPROCESS_H
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into the executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a separate directory
|
|
||||||
("lib/your_library_name/[Code]").
|
|
||||||
|
|
||||||
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
Example contents of `src/main.c` using Foo and Bar:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries by scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
; PlatformIO Project Configuration File
|
|
||||||
;
|
|
||||||
; Build options: build flags, source filter
|
|
||||||
; Upload options: custom upload port, speed and extra flags
|
|
||||||
; Library options: dependencies, extra library storages
|
|
||||||
; Advanced options: extra scripting
|
|
||||||
;
|
|
||||||
; Please visit documentation for the other options and examples
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
platform = espressif32
|
|
||||||
board = esp32dev
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
lib_deps = plerup/EspSoftwareSerial@^8.2.0
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
#include "SerialProcess.h"
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
SerialProcess::SerialProcess(int addr)
|
|
||||||
: address(addr), ndx(0), rc(0), newData(false), rcCheck(false) {
|
|
||||||
Serial.begin(115200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Processes Serial Input
|
|
||||||
void SerialProcess::SerialInput() {
|
|
||||||
while (Serial.available() > 0) {
|
|
||||||
rc = static_cast<char>(Serial.read());
|
|
||||||
|
|
||||||
if (rc == beginMarker) {
|
|
||||||
rcCheck = true; // Start reading after the begin marker
|
|
||||||
ndx = 0; // Reset index for new message
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rcCheck) {
|
|
||||||
// Store the character if within bounds
|
|
||||||
if (ndx < numChars - 1) {
|
|
||||||
receivedChars[ndx++] = rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for end marker
|
|
||||||
if (rc == endMarker) {
|
|
||||||
receivedChars[ndx] = '\0'; // Null-terminate the string
|
|
||||||
newData = true; // Mark new data as available
|
|
||||||
rcCheck = false; // Stop reading until the next begin marker
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if new data is available
|
|
||||||
bool SerialProcess::isNewDataAvailable() {
|
|
||||||
return newData;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the received data
|
|
||||||
char* SerialProcess::getReceivedData() {
|
|
||||||
if (newData) {
|
|
||||||
newData = false; // Reset the flag after accessing the data
|
|
||||||
return receivedChars;
|
|
||||||
}
|
|
||||||
return nullptr; // No new data
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the received message
|
|
||||||
void SerialProcess::getPayload(char *payload) {
|
|
||||||
if (newData) {
|
|
||||||
uint8_t source;
|
|
||||||
uint8_t destination;
|
|
||||||
char data[255]; // Allocate a buffer for the data
|
|
||||||
int parsed = sscanf(receivedChars, "#%hhu:%hhu:%63s;", &source, &destination, data);
|
|
||||||
if (parsed == 3 && destination == address) { // Ensure all fields are parsed correctly
|
|
||||||
strcpy(payload, data); // Copy data to the provided buffer
|
|
||||||
newData = false; // Mark the data as processed
|
|
||||||
} else if (address != source) {
|
|
||||||
Serial.print(receivedChars); // Forward the message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a message in the correct format
|
|
||||||
void SerialProcess::sendMessage(int receiver, const char* payload) {
|
|
||||||
Serial.printf("#%u:%u:%s;", address, receiver, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SerialProcess::changeAddress(int addr) {
|
|
||||||
address = addr; // Update the device address
|
|
||||||
}
|
|
||||||
@@ -1,238 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#include "SerialProcess.h"
|
|
||||||
|
|
||||||
#define LEDRED 14
|
|
||||||
#define LEDORANGE 13
|
|
||||||
#define LEDGREEN 12
|
|
||||||
|
|
||||||
unsigned long previousMillis = 0;
|
|
||||||
const unsigned long greenDuration = 5000;
|
|
||||||
const unsigned long yellowDuration = 2000;
|
|
||||||
const unsigned long redDuration = 5000;
|
|
||||||
const unsigned long transitionDuration = 2000;
|
|
||||||
const unsigned long heartbeatInterval = 1000;
|
|
||||||
const unsigned long heartbeatTimeout = 3000;
|
|
||||||
const unsigned long blinkInterval = 500;
|
|
||||||
unsigned long lastHeartbeatMillis = 0;
|
|
||||||
unsigned long lastBlinkMillis = 0;
|
|
||||||
bool blinkState = false;
|
|
||||||
|
|
||||||
enum State { GREEN, YELLOW, RED, TRANSITION, ERROR };
|
|
||||||
State currentState = GREEN;
|
|
||||||
|
|
||||||
const char *slavecheck = "#slvchck;";
|
|
||||||
const char *slaveack = "#slvack;";
|
|
||||||
const char *masterack = "#mstack;";
|
|
||||||
|
|
||||||
const char *turnRed = "tr";
|
|
||||||
const char *turnOrange = "to";
|
|
||||||
const char *turnGreen = "tg";
|
|
||||||
const char *heartbeat = "hb";
|
|
||||||
|
|
||||||
int node; // other bord addres number
|
|
||||||
int address = 0; // Device address
|
|
||||||
|
|
||||||
void setRed(){
|
|
||||||
digitalWrite(LEDRED, HIGH);
|
|
||||||
digitalWrite(LEDORANGE, LOW);
|
|
||||||
digitalWrite(LEDGREEN, LOW);
|
|
||||||
}
|
|
||||||
void setOrange(){
|
|
||||||
digitalWrite(LEDRED, LOW);
|
|
||||||
digitalWrite(LEDORANGE, HIGH);
|
|
||||||
digitalWrite(LEDGREEN, LOW);
|
|
||||||
}
|
|
||||||
void setGreen(){
|
|
||||||
digitalWrite(LEDRED, LOW);
|
|
||||||
digitalWrite(LEDORANGE, LOW);
|
|
||||||
digitalWrite(LEDGREEN, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
SerialProcess serialcom(0);
|
|
||||||
|
|
||||||
bool MasterCheck() {
|
|
||||||
SerialProcess serialcomchecker(1000);
|
|
||||||
const unsigned long timeout = 2000;
|
|
||||||
unsigned long startTime = millis();
|
|
||||||
bool isMaster = true;
|
|
||||||
bool checkSent = false;
|
|
||||||
bool gotResponse = false;
|
|
||||||
|
|
||||||
delay(random(100, 600)); // Randomize startup slightly
|
|
||||||
|
|
||||||
Serial.print(slavecheck); // Send check to see if someone replies
|
|
||||||
checkSent = true;
|
|
||||||
|
|
||||||
while (millis() - startTime < timeout) {
|
|
||||||
if (Serial.available()) {
|
|
||||||
serialcomchecker.SerialInput();
|
|
||||||
char* payload = serialcomchecker.getReceivedData();
|
|
||||||
|
|
||||||
if (strcmp(payload, slavecheck) == 0) {
|
|
||||||
// Got a check while we also sent a check — respond and become SLAVE
|
|
||||||
Serial.print(slaveack);
|
|
||||||
isMaster = false;
|
|
||||||
break;
|
|
||||||
} else if (strcmp(payload, slaveack) == 0) {
|
|
||||||
// Got an ACK from the other side — we are master
|
|
||||||
Serial.print(masterack);
|
|
||||||
isMaster = true;
|
|
||||||
break;
|
|
||||||
} else if (strcmp(payload, masterack) == 0) {
|
|
||||||
// Got master ack — we must be slave
|
|
||||||
isMaster = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Failsafe: no response at all
|
|
||||||
if (!Serial.available() && !gotResponse) {
|
|
||||||
// Assume we are master
|
|
||||||
isMaster = true;
|
|
||||||
Serial.print(masterack);
|
|
||||||
}
|
|
||||||
|
|
||||||
return isMaster;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void updateLights() {
|
|
||||||
switch (currentState) {
|
|
||||||
case GREEN:
|
|
||||||
setGreen();
|
|
||||||
serialcom.sendMessage(node, turnGreen);
|
|
||||||
break;
|
|
||||||
case YELLOW:
|
|
||||||
setOrange();
|
|
||||||
serialcom.sendMessage(node, turnOrange);
|
|
||||||
break;
|
|
||||||
case RED:
|
|
||||||
setGreen();
|
|
||||||
serialcom.sendMessage(node, turnRed);
|
|
||||||
break;
|
|
||||||
case TRANSITION:
|
|
||||||
serialcom.sendMessage(node, turnOrange);
|
|
||||||
break;
|
|
||||||
case ERROR:
|
|
||||||
if (millis() - lastBlinkMillis >= blinkInterval) {
|
|
||||||
blinkState = !blinkState;
|
|
||||||
digitalWrite(LEDORANGE, blinkState ? HIGH : LOW);
|
|
||||||
lastBlinkMillis = millis();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendHeartbeat() {
|
|
||||||
serialcom.sendMessage(node,heartbeat);
|
|
||||||
Serial.println("Sent: Heartbeat");
|
|
||||||
}
|
|
||||||
|
|
||||||
void master(){
|
|
||||||
bool running = true;
|
|
||||||
while (running){
|
|
||||||
unsigned long currentMillis = millis();
|
|
||||||
|
|
||||||
if (currentMillis - lastHeartbeatMillis >= heartbeatInterval) {
|
|
||||||
sendHeartbeat();
|
|
||||||
lastHeartbeatMillis = currentMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentMillis - lastHeartbeatMillis > heartbeatTimeout) {
|
|
||||||
currentState = ERROR;
|
|
||||||
updateLights();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (currentState) {
|
|
||||||
case GREEN:
|
|
||||||
if (currentMillis - previousMillis >= greenDuration) {
|
|
||||||
currentState = YELLOW;
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
updateLights();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case YELLOW:
|
|
||||||
if (currentMillis - previousMillis >= yellowDuration) {
|
|
||||||
currentState = RED;
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
updateLights();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RED:
|
|
||||||
if (currentMillis - previousMillis >= redDuration) {
|
|
||||||
currentState = TRANSITION;
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
updateLights();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TRANSITION:
|
|
||||||
if (currentMillis - previousMillis >= transitionDuration) {
|
|
||||||
currentState = GREEN;
|
|
||||||
previousMillis = millis();
|
|
||||||
updateLights();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ERROR:
|
|
||||||
updateLights();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(115200);
|
|
||||||
pinMode(LEDGREEN, OUTPUT);
|
|
||||||
pinMode(LEDORANGE, OUTPUT);
|
|
||||||
pinMode(LEDRED, OUTPUT);
|
|
||||||
bool MorS = MasterCheck(); // Check if master or slave
|
|
||||||
//set address for master or slave
|
|
||||||
if (MorS == false){
|
|
||||||
address = 2; // Set address for this slave
|
|
||||||
node = 1; // Set address for master
|
|
||||||
} else {
|
|
||||||
address = 1; // Set address for this master
|
|
||||||
node = 2; // Set address for slave
|
|
||||||
}
|
|
||||||
previousMillis = millis();
|
|
||||||
lastHeartbeatMillis = millis();
|
|
||||||
updateLights();
|
|
||||||
setRed();
|
|
||||||
serialcom.changeAddress(address); // Set address for serial communication
|
|
||||||
}
|
|
||||||
|
|
||||||
void slave(){
|
|
||||||
bool running = true;
|
|
||||||
char *command;
|
|
||||||
while (running && Serial.available() > 0){
|
|
||||||
serialcom.SerialInput();
|
|
||||||
serialcom.getPayload(command);
|
|
||||||
if (strcmp(command, turnRed)) setRed();
|
|
||||||
else if (strcmp(command, turnOrange)) setOrange();
|
|
||||||
else if (strcmp(command, turnGreen)) setGreen();
|
|
||||||
else if (strcmp(command, heartbeat)) {
|
|
||||||
lastHeartbeatMillis = millis();
|
|
||||||
digitalWrite(LEDRED, LOW); // Reset the orange blink pattern
|
|
||||||
digitalWrite(LEDORANGE, LOW);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Serial.print("slave: unknown command");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (millis() - lastHeartbeatMillis > heartbeatTimeout) {
|
|
||||||
// Blink the red and yellow LEDs to indicate an error (orange light)
|
|
||||||
if (millis() - lastBlinkMillis >= blinkInterval) {
|
|
||||||
blinkState = !blinkState;
|
|
||||||
digitalWrite(LEDORANGE, blinkState ? HIGH : LOW);
|
|
||||||
lastBlinkMillis = millis();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop(){
|
|
||||||
serialcom.changeAddress(2);
|
|
||||||
if (address == 1) slave(); //master
|
|
||||||
else if (address == 2) slave(); //slave
|
|
||||||
else Serial.print("master slave issue");
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Test Runner and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
|
||||||
5
C/ES/PlatformIO/Projects/ES2_1_C/.gitignore
vendored
5
C/ES/PlatformIO/Projects/ES2_1_C/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
],
|
|
||||||
"unwantedRecommendations": [
|
|
||||||
"ms-vscode.cpptools-extension-pack"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
A header file is a file containing C declarations and macro definitions
|
|
||||||
to be shared between several project source files. You request the use of a
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Including a header file produces the same results as copying the header file
|
|
||||||
into each source file that needs it. Such copying would be time-consuming
|
|
||||||
and error-prone. With a header file, the related declarations appear
|
|
||||||
in only one place. If they need to be changed, they can be changed in one
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
new version when next recompiled. The header file eliminates the labor of
|
|
||||||
finding and changing all the copies as well as the risk that a failure to
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the convention is to give header files names that end with `.h'.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into the executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a separate directory
|
|
||||||
("lib/your_library_name/[Code]").
|
|
||||||
|
|
||||||
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
Example contents of `src/main.c` using Foo and Bar:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries by scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
; PlatformIO Project Configuration File
|
|
||||||
;
|
|
||||||
; Build options: build flags, source filter
|
|
||||||
; Upload options: custom upload port, speed and extra flags
|
|
||||||
; Library options: dependencies, extra library storages
|
|
||||||
; Advanced options: extra scripting
|
|
||||||
;
|
|
||||||
; Please visit documentation for the other options and examples
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:uno]
|
|
||||||
platform = atmelavr
|
|
||||||
board = uno
|
|
||||||
framework = arduino
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
int analogValue;
|
|
||||||
int readPin = 23;
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(115200);
|
|
||||||
pinMode(readPin,INPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
analogValue = analogRead(readPin);
|
|
||||||
Serial.print(analogValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Test Runner and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
],
|
|
||||||
"unwantedRecommendations": [
|
|
||||||
"ms-vscode.cpptools-extension-pack"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
A header file is a file containing C declarations and macro definitions
|
|
||||||
to be shared between several project source files. You request the use of a
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Including a header file produces the same results as copying the header file
|
|
||||||
into each source file that needs it. Such copying would be time-consuming
|
|
||||||
and error-prone. With a header file, the related declarations appear
|
|
||||||
in only one place. If they need to be changed, they can be changed in one
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
new version when next recompiled. The header file eliminates the labor of
|
|
||||||
finding and changing all the copies as well as the risk that a failure to
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the convention is to give header files names that end with `.h'.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into the executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a separate directory
|
|
||||||
("lib/your_library_name/[Code]").
|
|
||||||
|
|
||||||
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
Example contents of `src/main.c` using Foo and Bar:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries by scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
; PlatformIO Project Configuration File
|
|
||||||
;
|
|
||||||
; Build options: build flags, source filter
|
|
||||||
; Upload options: custom upload port, speed and extra flags
|
|
||||||
; Library options: dependencies, extra library storages
|
|
||||||
; Advanced options: extra scripting
|
|
||||||
;
|
|
||||||
; Please visit documentation for the other options and examples
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:esp32dev]
|
|
||||||
platform = espressif32
|
|
||||||
board = esp32dev
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
int analogValue;
|
|
||||||
int readPin = 32;
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(115200);
|
|
||||||
analogReadResolution(10);
|
|
||||||
pinMode(readPin,INPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
analogValue = analogRead(readPin);
|
|
||||||
Serial.println(840);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Test Runner and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
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}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"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": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"runtimeOptions": {
|
|
||||||
"tfm": "net8.0",
|
|
||||||
"framework": {
|
|
||||||
"name": "Microsoft.NETCore.App",
|
|
||||||
"version": "8.0.0"
|
|
||||||
},
|
|
||||||
"configProperties": {
|
|
||||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
// <autogenerated />
|
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <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.
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
77da79aa1d8b67801697281643b61dd3f4e48c0c7f245ecd395dee391118be92
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
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 =
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// <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;
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
63f646a6f5c36f8a67f54301cd756f80709a6758f27e90e85bd3caa85964b27d
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/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
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
4028af397b722be4e5490a9f64106d4a5c363b00c8703dae917b145b5632baa4
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"dgSpecHash": "0d5jt8ngUw0=",
|
|
||||||
"success": true,
|
|
||||||
"projectFilePath": "/home/rens/T2/CS/Starter_assignment/Starter_assignment/Starter_assignment.csproj",
|
|
||||||
"expectedPackageFiles": [],
|
|
||||||
"logs": []
|
|
||||||
}
|
|
||||||
@@ -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","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"}}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
17406469005085962
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
17406469005085962
|
|
||||||
Reference in New Issue
Block a user