From 9c717409eaac3f65055f6cdd80aeb3da2a0cb3f1 Mon Sep 17 00:00:00 2001
From: Michael Ghebremussie
 <michael.ghebremussie@student.reutlingen-university.de>
Date: Mon, 12 Dec 2022 15:43:18 +0000
Subject: [PATCH] added Comments and changed the Function- and Variable names.

---
 Aufgabe3/ConsoleApplication1/Buffer.cs | 63 +++++++++++---------------
 1 file changed, 26 insertions(+), 37 deletions(-)

diff --git a/Aufgabe3/ConsoleApplication1/Buffer.cs b/Aufgabe3/ConsoleApplication1/Buffer.cs
index cb5d1bc..7de3950 100644
--- a/Aufgabe3/ConsoleApplication1/Buffer.cs
+++ b/Aufgabe3/ConsoleApplication1/Buffer.cs
@@ -4,70 +4,59 @@ using System.Threading;
 
 namespace ConsoleApplication1
 {
-    /// <summary>
-    /// Creating a Class Buffer that contains a Queue that represent the "Parking lot".
-    /// The Queue is limited by the size that can manually be setted
-    /// </summary>
-
+    
     public class Buffer
     {
-        private Queue<Car> carQueue;
-        private int size = 10;
-        private Mutex mutex;
+        private Queue<Car> _carQueue;
+        private int _size = 10;
+        private Mutex _mutex;
 
+        // Constructor initialized with a Mutex and a Queue.
         public Buffer()
         {
-            mutex = new Mutex();
-            carQueue = new Queue<Car>();
+            _mutex = new Mutex();
+            _carQueue = new Queue<Car>();
         }
 
-        public void push(Car c)
+        // This function adds a Car Object into the Queue.
+        public void Push(Car c)
         {
-            if (carQueue.Count == size)
+            // Check whether the Queue is full and throws an Exception if so.
+            if (_carQueue.Count == _size)
             {
                 throw new Exception("Buffer full");
-            }
-            
+            }  
             
-            carQueue.Enqueue(c);
+            _carQueue.Enqueue(c);
         }
 
-        public Car pop()
+        // Removes a Car Object from the Queue and returns the Queue.
+        public Car Pop()
         {
-            if (carQueue.Count == 0)
+            if (_carQueue.Count == 0)
             {
                 throw new Exception("Buffer empty");
             }
 
-            return carQueue.Dequeue();
+            return _carQueue.Dequeue();
         }
 
-        public bool full()
+        // Check if the Queue is full.
+        public bool Full()
         {
-            bool isFull = false;
-            if (carQueue.Count == size)
-            {
-                isFull = true;
-            }
-
-            return isFull;
+            return _carQueue.Count == _size;
         }
 
-        public bool empty()
+        // Check if the Queue is empty.
+        public bool Empty()
         {
-            if (carQueue.Count == 0)
-            {
-                return true;
-            }
-
-            return false;
+            return _carQueue.Count == 0;
         }
 
-        public Mutex getMutex()
+        // returns the Mutex. 
+        public Mutex GetMutex()
         {
-            return this.mutex;
+            return this._mutex;
         }
-
-
     }
 }
-- 
GitLab