--- id: 587d8250367417b2b2512c60 title: Create a Queue Class challengeType: 1 videoUrl: '' localeTitle: '' --- ## Description
مثل الأكوام ، الطوابير عبارة عن مجموعة من العناصر. ولكن على عكس المداخن ، تتبع الطوابير مبدأ FIFO (أولاً في أول). يتم دفع العناصر المضافة إلى قائمة انتظار إلى الذيل ، أو نهاية ، قائمة الانتظار ، ويسمح فقط بإزالة العنصر الموجود في الجزء الأمامي من قائمة الانتظار. يمكننا استخدام مصفوفة لتمثيل طابور ، ولكن مثل المداخن ، نريد أن نحدد كمية التحكم التي لدينا على قوائم الانتظار لدينا. تتمثل الطريقتان الرئيسيتان لطبقة صف الانتظار في الطوق وطريقة dequeue. تدفع طريقة enqueue عنصرًا إلى ذيل قائمة الانتظار ، ويزيل أسلوب dequeue ويعيد العنصر في مقدمة الصف. طرق أخرى مفيدة هي الجبهة ، والحجم ، وأساليب فارغة. التعليمات قم بكتابة طريقة تعامدية توجه عنصرًا إلى ذيل قائمة الانتظار ، وهي طريقة dequeue تقوم بإزالة وإرجاع العنصر الأمامي ، وهي طريقة أمامية تسمح لنا برؤية العنصر الأمامي ، وطريقة الحجم التي تعرض الطول ، والطريقة isEmpty لمعرفة ما إذا كانت قائمة الانتظار فارغة.
## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert((function(){var test = new Queue(); return (typeof test.enqueue === "function")}()), "Your Queue class should have a enqueue method.");' - text: '' testString: 'assert((function(){var test = new Queue(); return (typeof test.dequeue === "function")}()), "Your Queue class should have a dequeue method.");' - text: '' testString: 'assert((function(){var test = new Queue(); return (typeof test.front === "function")}()), "Your Queue class should have a front method.");' - text: '' testString: 'assert((function(){var test = new Queue(); return (typeof test.size === "function")}()), "Your Queue class should have a size method.");' - text: '' testString: 'assert((function(){var test = new Queue(); return (typeof test.isEmpty === "function")}()), "Your Queue class should have an isEmpty method.");' - text: يجب أن تقوم طريقة dequeue بإزالة وإعادة العنصر الأمامي لقائمة الانتظار testString: 'assert((function(){var test = new Queue(); test.enqueue("Smith"); return (test.dequeue() === "Smith")}()), "The dequeue method should remove and return the front element of the queue");' - text: '' testString: 'assert((function(){var test = new Queue(); test.enqueue("Smith"); test.enqueue("John"); return (test.front() === "Smith")}()), "The front method should return value of the front element of the queue");' - text: '' testString: 'assert((function(){var test = new Queue(); test.enqueue("Smith"); return (test.size() === 1)}()), "The size method should return the length of the queue");' - text: '' testString: 'assert((function(){var test = new Queue(); test.enqueue("Smith"); return !(test.isEmpty())}()), "The isEmpty method should return false if there are elements in the queue");' ```
## Challenge Seed
```js function Queue () { var collection = []; this.print = function() { console.log(collection); }; // Only change code below this line // Only change code above this line } ```
## Solution
```js // solution required ```