Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone finish all of my methods for me here is my code below import java.util.ArrayList; import java.util.Collection; import java.util.Deque; import java.util.Iterator; public class FixedSizedDeque

Can anyone finish all of my methods for me here is my code below

import java.util.ArrayList;

import java.util.Collection;

import java.util.Deque;

import java.util.Iterator;

public class FixedSizedDeque implements Deque {

public static void main(String args[]) { FixedSizedDeque myDeque = new FixedSizedDeque<>(5); myDeque.addFirst(4); myDeque.addFirst(5); System.out.println(myDeque.removeFirst()); System.out.println(myDeque.removeFirst());}

ArrayList deQueue;

int size;

public FixedSizedDeque(int maxSize) {

//TODO

deQueue = new ArrayList<>();

size = 0;

}

@Override

public boolean addAll(Collection arg0) {

return false;

}

@Override

public void clear() {

deQueue.clear();

}

@Override

public boolean containsAll(Collection arg0) {

return deQueue.containsAll(arg0);

}

@Override

public boolean isEmpty() {

return size == 0;

}

@Override

public boolean removeAll(Collection arg0) {

return deQueue.removeAll(arg0);

}

@Override

public boolean retainAll(Collection arg0) {

return deQueue.retainAll(arg0);

}

@Override

public Object[] toArray() {

return deQueue.toArray();

}

@SuppressWarnings("hiding")

@Override

public T[] toArray(T[] arg0) {

return deQueue.toArray(arg0);

}

@Override

public boolean add(T arg0) {

boolean res = deQueue.add(arg0);

if(res)

size++;

return res;

}

@Override

public void addFirst(T arg0) {

deQueue.add(0, arg0);

size++;

}

@Override

public void addLast(T arg0) {

add(arg0);

}

@Override

public boolean contains(Object arg0) {

return deQueue.contains(arg0);

}

@Override

public Iterator descendingIterator() {

return deQueue.iterator();

}

@Override

public T element() {

return null;

}

@Override

public T getFirst() {

return null;

}

@Override

public T getLast() {

return null;

}

@Override

public Iterator iterator() {

return null;

}

@Override

public boolean offer(T arg0) {

return add(arg0);

}

@Override

public boolean offerFirst(T arg0) {

addFirst(arg0);

return true;

}

@Override

public boolean offerLast(T arg0) {

addLast(arg0);

return true;

}

@Override

public T peek() {

return null;

}

@Override

public T peekFirst() {

return null;

}

@Override

public T peekLast() {

return null;

}

@Override

public T poll() {

return null;

}

@Override

public T pollFirst() {

return null;

}

@Override

public T pollLast() {

return null;

}

@Override

public T pop() {

return null;

}

@Override

public void push(T arg0) {

}

@Override

public T remove() {

return null;

}

@Override

public boolean remove(Object arg0) {

return false;

}

@Override

public T removeFirst() {

return deQueue.remove(0);

}

@Override

public boolean removeFirstOccurrence(Object arg0) {

return false;

}

@Override

public T removeLast() {

return deQueue.remove(size-1);

}

@Override

public boolean removeLastOccurrence(Object arg0) {

return false;

}

@Override

public int size() {

return size;

}

}

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago