Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

12. Write a complete method from the implementation perspective called getSomeEntry(). The method will be in the ArrayBag class. ArrayBag implements BagInterface using an array.

12. Write a complete method from the implementation perspective called getSomeEntry(). The method will be in the ArrayBag class.

ArrayBag implements BagInterface using an array.

The method returns an unspecified entry of the ArrayBag. You can decide which entry to return.

Be sure to account for all possible times when the method could be invoked. Your code should not crash.

The method header is:

public T getSomeEntry() 

For this question, you are writing code at the implementation level. This means you have access to the private instance data variables:

private T[] bag private int numberOfEntries 

You can assume the following methods are already implemented:

public boolean add(T newEntry) public boolean isEmpty() public boolean contains(T anObject) public T remove() public boolean remove(T anEntry) public int getFrequencyOf(T anEntry) public int getCurrentSize() public void clear() 

19.

Write a complete method to traverse a linked list of Integers and count the number of even numbers on the list. You are given the first node in the list. The method header is:

public static int countEvens(Node node) 

You can assume the data and next fields of the Node class are public.

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

4. Describe cultural differences that influence perception

Answered: 1 week ago