Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Consider the following interface: // a CBListADT is a cursor based list of char // a newly created CBListADT is empty (contains no elements) public interface CBListADT { // get the current element...

1 answer below »
Consider the following interface:
a CBListADT is a cursor based list of cha
a newly created CBListADT is empty (contains no elements)
public interface CBListADT {

get the cu
ent element
public char get();

insert c before the cu
ent element
public void insert(char c);

remove the cu
ent element. return true if it was possible to do, false if not
public boolean remove();

move the cursor so that the first element is the cu
ent element
public void moveToFirst();

move the cursor to the next element, returning true if the move succeeded

and false if it is not possible to move to the next element
public boolean goNext();
}
Type your answers in the lines indicated by A1, A2, ... A7. Add lines if needed.
--------------------------------------------------------------------------------------
Q1.
Write a problem instance that describes the behavior of the remove()
method when the CBListADT has the following initial state:
a | b, c
A1:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q2.
Write one sentence that explains your problem instance.
A2:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q3.
Write a JUnit test method that implements your problem instance. Assume that a class
named CBListRaIMP exists that implements CBListADT. Assume all the methods
are implemented.
A3:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q4.
Briefly explain each step in the JUnit method you wrote.
A4:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q5.
Write a class named CBListRaIMP that implements the CBListADT interface using an a
ay
of char. Be sure to include any necessary data fields. NOTE: you only have to implement
the remove() method.
A5:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q6.
Write a short paragraph explaining your CBListRaIMP implementation. Be sure to state the
ole of each data field and to explain each step in your method implementation.
A6:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Consider the method foo in the class Moo below.
public class Moo {
public static boolean foo(char[] a, int b, int c) {
XXXXXXXXXXif (b == a.length) {
XXXXXXXXXXreturn false;
}
XXXXXXXXXXif (c < 0 || b < c) {
XXXXXXXXXXreturn false;
}
XXXXXXXXXXfor (int i = b; i > c; i--) {
XXXXXXXXXXa[i] = a[i - 1];
}
        a[c] = 'x';
XXXXXXXXXXreturn true;
}
}
Type your answers in the lines indicated by A1, A2 (add lines if needed).
--------------------------------------------------------------------------------------
Q1.
Explain how method foo works. Be sure to explain what its parameters are and how it
uses them. State what each line in the method does.
A1:
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q2.
State in ONE sentence what the purpose of method foo is. (Do NOT explain the steps
method foo performs. That is the first question.)
A2:
--------------------------------------------------------------------------------------
Answered 3 days After Oct 11, 2021

Solution

Swapnil answered on Oct 14 2021
123 Votes
Consider the following interface:
a CBListADT is a cursor based list of cha
a newly created CBListADT is empty (contains no elements)
public interface CBListADT {

get the cu
ent element
public char get();

insert c before the cu
ent element
public void insert(char c);

remove the cu
ent element. return true if it was possible to do, false if not
public boolean remove();

move the cursor so that the first element is the cu
ent element
public void moveToFirst();

move the cursor to the next element, returning true if the move succeeded

and false if it is not possible to move to the next element
public boolean goNext();
}
Type your answers in the lines indicated by A1, A2, ... A7. Add lines if needed.
--------------------------------------------------------------------------------------
Q1.
Write a problem instance that describes the behavior of the remove()
method when the CBListADT has the following initial state:
a | b, c
A1:
• The remove () method removes the element in the specified list of CBListADT interface.
• If the initial state is then the CBListADT interface create the problem for
• bitwise or operation for giving the true false condition in the remove() method.
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q2.
Write one sentence that explains your problem instance.
A2:
• For the condition the instance variable gives the condition for non-static
variables which is basically defined outside the class interface.
• So In the above example the is not defined in the remove() method.
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Q3.
Write a JUnit test method that implements your problem instance. Assume that a class
named CBListRaIMP exists that implements CBListADT. Assume all the methods
are implemented.
A3:
package com.java.testcase;
import static org.junit.Assert.*;
import org.junit.Test;
public class CBListRaIMPTest
{
public CBListRaIMP createInstance();
@Test
default void testCBListRaIMP_True()
{
CBListRaIMP instance = createInstance();
assertTrue(instance.CBListRaIMP(true));
}
@Test
default void testCBListRaIMP_False()
{
CBListRaIMP instance =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here