Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am currently learning about Queues in Java, and cannot figure out how to complete this lab, any help is greatly appreciated. IntQueue: import java.util.ArrayList;

I am currently learning about Queues in Java, and cannot figure out how to complete this lab, any help is greatly appreciated.image text in transcribed

IntQueue:

import java.util.ArrayList; import static java.lang.System.*; public class IntQueue { //pick your storage for the queue //you can use the an array or an ArrayList //option 1 private int[] rayOfInts; private int numInts; //option 2 private ArrayList listOfInts; public IntQueue() { } public void add(int item) { } public int remove() { return 0; } public boolean isEmpty() { return false; } public int peek() { return 0; } public String toString() { return ""; } }

IntQueueRunner:

import java.util.ArrayList; import static java.lang.System.*; public class IntQueueRunner { public static void main ( String[] args ) { IntQueue test = new IntQueue(); test.add(5); test.add(7); test.add(9); System.out.println(test); System.out.println(test.isEmpty()); System.out.println(test.remove()); System.out.println(test.peek()); System.out.println(test.remove()); System.out.println(test.remove()); System.out.println(test.isEmpty()); System.out.println(test); } }

A+ Computer Science MAKE A QUEUE Lab Goal: This lab was designed to teach you more about queues. Lab Description : You are to create a queue from scratch using either an array or an ArrayList as the storage for the queue. Starting Class : class IntQueue { //pick your storage for the queue //you can use the an array or an ArrayList Files Needed :: IntQueue.java IntQueueRunner.java 1/option 1 private int[] rayofInts; private int numInts; 1/option 2 private ArrayList listofInts; public IntQueue () { } public void add (int item) { } public int remove() { return 0; } public boolean isEmpty() { return false; } public int peek () { return 0; } public String toString() { return ""; } } Sample Data : see lab Sample Output : [5, 7, 9) false 5 7 7 9 A+ Computer Science - Queue Lab - www.apluscompsci.com true []

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions