From 110a841ba001594130c119edcbf0da46c1351cdf Mon Sep 17 00:00:00 2001 From: Michael Ghebremussie <Michael.ghebremussie@student.reutlingen-university.de> Date: Mon, 12 Dec 2022 17:06:37 +0100 Subject: [PATCH] Added Exception for the Queue --- Aufgabe3/ConsoleApplication1/Buffer.cs | 19 ++++++++++++++++-- ...pplication1.csproj.AssemblyReference.cache | Bin 2014 -> 2014 bytes 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Aufgabe3/ConsoleApplication1/Buffer.cs b/Aufgabe3/ConsoleApplication1/Buffer.cs index eb56cb3..9206286 100644 --- a/Aufgabe3/ConsoleApplication1/Buffer.cs +++ b/Aufgabe3/ConsoleApplication1/Buffer.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; using System.Threading; namespace ConsoleApplication1 @@ -25,7 +27,7 @@ namespace ConsoleApplication1 // Check whether the Queue is full and throws an Exception if so. if (_carQueue.Count == _size) { - throw new Exception("Buffer full"); + throw new QueueFullException("Buffer full"); } _carQueue.Enqueue(c); @@ -36,7 +38,7 @@ namespace ConsoleApplication1 { if (_carQueue.Count == 0) { - throw new Exception("Buffer empty"); + throw new QueueEmptyException("Buffer empty"); } return _carQueue.Dequeue(); @@ -60,4 +62,17 @@ namespace ConsoleApplication1 return this._mutex; } } + +} + +public class QueueEmptyException : Exception +{ + public QueueEmptyException(string bufferEmpty) + : base (bufferEmpty) { } +} + +public class QueueFullException : Exception +{ + public QueueFullException(string bufferEmpty) + : base (bufferEmpty) { } } diff --git a/Aufgabe3/ConsoleApplication1/obj/Debug/ConsoleApplication1.csproj.AssemblyReference.cache b/Aufgabe3/ConsoleApplication1/obj/Debug/ConsoleApplication1.csproj.AssemblyReference.cache index 20fe956fbd936cfdf51efb2a56bfa03f84449a55..eb48dfe115ae819b39829865d0424213d303e6e2 100644 GIT binary patch delta 69 zcmcb|e~*8HJ3B*XnN)<xt%-gw*?#;=%F@5J*_P3kk)5IC-iZhxr;(|G2`2HMWg#OQ PM11mpmMN31*p~nR1d$$g delta 69 zcmcb|e~*8HJNxg9DM2?k-<;_8lI`Du^T}1$H`_AWGO`~qevkkZ-rUGk!32}|&$5t_ UZ9%*9$MWlw|FcY)Y{k9=0L$<qqyPW_ -- GitLab