
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Please Use java only.
Inthisassignment,youwillimplementaclasscalledCustomIntegerArrayList. Thisclass represents a fancy ArrayList that stores integers and supports additional operations not included in Java's built-in ArrayList methods.
For example, the CustomIntegerArrayList class has a “splice” method which removes a specified number of elements from the CustomIntegerArrayList, starting at a given index. For a CustomIntegerArrayList that includes: 1, 2, 3, 4, and 5, calling splice(1, 2) will remove 2 items starting at index 1. This will remove 2 and 3 (the 2nd and 3rd items).
The Cu stomIntegerArrayList class has 2 different (overloaded) constructors. (Remember, an overloaded constructor is a constructor that has the same name, but a different number, type, or sequence of parameters, as another constructor in the class.) Having 2 different constructors means you can create an instance of the CustomIntegerArrayList class in 2 different ways, depending on which constructor you call. Both constructors have been implemented for you. (See below)
Internally, the CustomIntegerArrayList class uses a private ArrayList variable named “arr” to store its integer elements. The “CustomIntegerArrayList()” constructor initializes the ArrayList variable “arr” as an empty ArrayList and the “CustomIntegerArrayList(ArrayList arr)” constructor initializes the ArrayList variable “arr” with the elements in the given ArrayList. (Again, see below)
/**
* Fancy ArrayList that stores integers and supports additional
operations not included in Java's built-in ArrayList methods. */
Introduction to Java & Object Oriented Programming
public class CustomIntegerArrayList { // instance variables
/**
* Internal ArrayList of elements. */
private ArrayList arr;
// constructors
/**
* Creates a new empty CustomIntegerArrayList. */
public CustomIntegerArrayList() { this.arr = new ArrayList();
}
/**
* Creates a new CustomIntegerArrayList with the elements in
the given ArrayList.
* @param arr with elements for the CustomIntegerArrayList */
public CustomIntegerArrayList(ArrayList arr) {
this.arr = new ArrayList(arr); }
There are 8 (mostly overloaded) methods that need to be implemented in the CustomIntegerArrayList c lass. (Again, an overloaded method is a method that has the same name, but a different number, type, or sequence of parameters, as another method in the same class.)
● getArrayList() - Returns the elements.
● get(int index) - Returns the element at the specified index from the elements.
● add(int element) - Appends the given element to the end of the elements.
● add(int index, int element) - Inserts the given element at the specified index.
● remove(int index) - Removes the element at the specified index.
● remove(int num, int element) - Removes the specified number of the given element
from all elements.
● splice(int index, int num) - Removes the specified number of elements from all
elements, starting at the given index.
● splice(int index, int num, int[] otherArray) - Removes the specified number of elements
from all elements, starting at the given index, and inserts new elements in the given array at the given index.
Each method has been defined for you, but without the code. See the javadoc for each method for instructions on what the method is supposed to do and how to write the code. It should be clear enough. In some cases, we have provided hints and example method calls to help you get started.
For example, we have defined a “remove” method for you (see below) which removes a specified number of a given element from the CustomIntegerArrayList. Read the javadoc, which explains what the method is supposed to do. Then write your code where it says “// TODO” to implement the method. You’ll do this for each method in the program.
/**
* Removes the specified number (num) of the given element from the
internal ArrayList of elements.
* If num lst1 = new ArrayList(); lst1.add(0, 2);
lst1.add(0, 3);
lst1.add(0, 4);
lst1.remove(0);
lst1.remove(1);
assertEquals(arr1.get(0), lst1.get(0));
// TODO write at least 3 additional test cases }
The main method calls have been provided for you (see example below). They are designed purely to call the other methods in the program, and to help you run the program. Nothing needs to be completed in the main method.
public static void main(String args[]) {
//create new empty CustomIntegerArrayList CustomIntegerArrayList arr1 = new CustomIntegerArrayList();
//add element arr1.add(2);
//get internal arraylist of elements
System.out.println(arr1.getArrayList()); //[2] }
You have been provided with CustomIntegerArrayList.java and CustomIntegerArrayListTest.java. To complete the assignment, implement the methods in CustomIntegerArrayList.java, making sure you pass all the tests in CustomIntegerArrayListTest.java. Then write at least 3 additional and distinct test cases for each unit test method in CustomIntegerArrayListTest.java. Do not modify the name of the methods in C ustomIntegerArrayList.java or the automated testing will not recognize it.
![• Unit Testing
The Assignment
In this assignment, you will implement a class called CustomintegerArrayList. This class
represents a fancy ArrayList that stores integers and supports additional operations not
included in Java's built-in ArrayList methods.
For example, the CustomintegerArrayList class has a "splice" method which removes a
specified number of elements from the CustomintegerArrayList, starting at a given index. For a
CustomintegerArrayList that includes: 1, 2, 3, 4, and 5, calling splice(1, 2) will remove 2 items
starting at index 1. This will remove 2 and 3 (the 2nd and 3rd items).
The CustomintegerArrayList class has 2 different (overloaded) constructors. (Remember, an
overloaded constructor is a constructor that has the same name, but a different number, type,
or sequence of parameters, as another constructor in the class.) Having 2 different
constructors means you can create an instance of the CustomintegerArrayList class in 2
different ways, depending on which constructor you call. Both constructors have been
implemented for you. (See below)
Internally, the CustomintegerArrayList class uses a private ArrayList variable named "arr" to
store its integer elements. The "CustomlntegerArrayList()" constructor initializes the ArrayList
variable "arr" as an empty ArrayList and the "CustomintegerArrayList(ArrayList<Integer> arr)"
constructor initializes the ArrayList variable "arr" with the elements in the given ArrayList.
(Again, see below)
/**
* Fancy ArrayList that stores integers and supports additional
operations not included in Java's built-in ArrayList methods.
APenn
Engineering
ONLINE LEARNNG
Introduction to Java & Object Oriented Programming
public class CustomIntegerArrayList {
// instance variables
/**
* Internal ArrayList of elements.
*/
private ArrayList<Integer> arr;
// constructors
* Creates a new empty CustomintegerArrayList.
public CustomIntegerArrayList () {
this.arr - new ArrayList<Integer> ():
/**
* Creates a new CustomIntegerArrayList with the elements in
the given ArrayList.
* eparam arr with elements for the CustomIntegerArrayList
*/
public CustomIntegerArrayList (ArrayList<Integer> arr) {
this.arr - new ArrayList<Integer> (arr);
There are 8 (mostly overloaded) methods that need to be implemented in the
CustomintegerArrayList class. (Again, an overloaded method is a method that has the same
name, but a different number, type, or sequence of parameters, as another method in the same
class.)
• getArrayList() - Returns the elements.
• getlint index) - Returns the element at the specified index from the elements.
• addſint element) - Appends the given element to the end of the elements.
• addſint index, int element) - Inserts the given element at the specified index.
• remove(int index) - Removes the element at the specified index.
• remove(int num, int element) - Removes the specified number of the given element
from all elements.
• splice(int index, int num) - Removes the specified number of elements from all
elements, starting at the given index.
• splice(int index, int num, int] otherArray) - Removes the specified number of elements
from all elements, starting at the given index, and inserts new elements in the given
array at the given index.
Penn](https://content.bartleby.com/qna-images/question/a4946c40-85e7-4bdb-afce-1b8e9a9b2811/1158387a-d9b7-4761-952f-793c4701c939/2xj87uo_thumbnail.jpeg)
Transcribed Image Text:• Unit Testing
The Assignment
In this assignment, you will implement a class called CustomintegerArrayList. This class
represents a fancy ArrayList that stores integers and supports additional operations not
included in Java's built-in ArrayList methods.
For example, the CustomintegerArrayList class has a "splice" method which removes a
specified number of elements from the CustomintegerArrayList, starting at a given index. For a
CustomintegerArrayList that includes: 1, 2, 3, 4, and 5, calling splice(1, 2) will remove 2 items
starting at index 1. This will remove 2 and 3 (the 2nd and 3rd items).
The CustomintegerArrayList class has 2 different (overloaded) constructors. (Remember, an
overloaded constructor is a constructor that has the same name, but a different number, type,
or sequence of parameters, as another constructor in the class.) Having 2 different
constructors means you can create an instance of the CustomintegerArrayList class in 2
different ways, depending on which constructor you call. Both constructors have been
implemented for you. (See below)
Internally, the CustomintegerArrayList class uses a private ArrayList variable named "arr" to
store its integer elements. The "CustomlntegerArrayList()" constructor initializes the ArrayList
variable "arr" as an empty ArrayList and the "CustomintegerArrayList(ArrayList<Integer> arr)"
constructor initializes the ArrayList variable "arr" with the elements in the given ArrayList.
(Again, see below)
/**
* Fancy ArrayList that stores integers and supports additional
operations not included in Java's built-in ArrayList methods.
APenn
Engineering
ONLINE LEARNNG
Introduction to Java & Object Oriented Programming
public class CustomIntegerArrayList {
// instance variables
/**
* Internal ArrayList of elements.
*/
private ArrayList<Integer> arr;
// constructors
* Creates a new empty CustomintegerArrayList.
public CustomIntegerArrayList () {
this.arr - new ArrayList<Integer> ():
/**
* Creates a new CustomIntegerArrayList with the elements in
the given ArrayList.
* eparam arr with elements for the CustomIntegerArrayList
*/
public CustomIntegerArrayList (ArrayList<Integer> arr) {
this.arr - new ArrayList<Integer> (arr);
There are 8 (mostly overloaded) methods that need to be implemented in the
CustomintegerArrayList class. (Again, an overloaded method is a method that has the same
name, but a different number, type, or sequence of parameters, as another method in the same
class.)
• getArrayList() - Returns the elements.
• getlint index) - Returns the element at the specified index from the elements.
• addſint element) - Appends the given element to the end of the elements.
• addſint index, int element) - Inserts the given element at the specified index.
• remove(int index) - Removes the element at the specified index.
• remove(int num, int element) - Removes the specified number of the given element
from all elements.
• splice(int index, int num) - Removes the specified number of elements from all
elements, starting at the given index.
• splice(int index, int num, int] otherArray) - Removes the specified number of elements
from all elements, starting at the given index, and inserts new elements in the given
array at the given index.
Penn
![ONLINE LEARNING
Introduction to Java & Object Oriented Programming
Each method has been defined for you, but without the code. See the javadoc for each method
for instructions on what the method is supposed to do and how to write the code. It should be
clear enough. In some cases, we have provided hints and example method calls to help you
get started.
For example, we have defined a "remove" method for you (see below) which removes a
specified number of a given element from the CustomlntegerArrayList. Read the javadoc,
which explains what the method is supposed to do. Then write your code where it says ""
TODO" to implement the method. You'll do this for each method in the program.
/**
* Removes the specified number (num) of the given element from the
internal ArrayList of elements.
* If num <= 0, don't remove anything.
* If num is too large, remove all instances of the given element
from the internal ArrayList of elements.
* @param num number of instances of element to remove
* @param element to remove
*/
public void remove (int num, int element) {
// TODO Implement method
In addition, you will write unit tests to test your method implementations. Each unit test
method has been defined for you, including some test cases. First make sure you pass all of
the provided tests, then write additional and distinct test cases for each unit test method.
For example, we have defined a "testRemovelnt" method for you (see below) which tests the
"remove" method. Pass the tests provided then write additional tests where it says "// TODO".
You'll do this for each unit test method in the program.
eTest
void testRemoveInt () {
CustomIntegerArrayList arrl - new CustomIntegerArrayList ();
arrl.add (0, 2):
arrl.add (0, 3):
arrl.add (0, 4);
arrl.remove (0):
arrl.remove (1):
Penn
Engineering
TONLINE LEARNING
Introduction to Java & Object Oriented Programming
ArrayList<Integer> 1stl = new ArrayList<Integer> () :
1stl.add (0, 2):
1st1.add (0, 3):
1st1.add (0, 4):
1stl.remove (0) :
1st1.remove (1):
assertEquals (arrl.get (0), 1stl.get (0)):
// TODO write at least 3 additional test cases
The main method calls have been provided for you (see example below). They are designed
purely to call the other methods in the program, and to help you run the program. Nothing
needs to be completed in the main method.
public static void main (String args(]) {
//create new empty CustomIntegerArrayList
CustomIntegerArrayList arrl ="new CustomIntegerArrayList ();
//add element
arrl.add (2):
//get internal arraylist of elements
System.out.printin (arrl.getArrayList ()): //12]
Submission
You have been provided with CustomintegerArrayListjava and
CustomintegerArrayListTest java. To complete the assignment, implement the methods in
CustomintegerArrayList.java, making sure you pass all the tests in
CustomintegerArrayListTest java. Then write at least 3 additional and distinct test cases for
each unit test method in CustomintegerArrayListTestjava. Do not modify the name of the
methods in CustomintegerArral.ist.iava or the automated testina will not recognize it.](https://content.bartleby.com/qna-images/question/a4946c40-85e7-4bdb-afce-1b8e9a9b2811/1158387a-d9b7-4761-952f-793c4701c939/tdsmpkv_thumbnail.jpeg)
Transcribed Image Text:ONLINE LEARNING
Introduction to Java & Object Oriented Programming
Each method has been defined for you, but without the code. See the javadoc for each method
for instructions on what the method is supposed to do and how to write the code. It should be
clear enough. In some cases, we have provided hints and example method calls to help you
get started.
For example, we have defined a "remove" method for you (see below) which removes a
specified number of a given element from the CustomlntegerArrayList. Read the javadoc,
which explains what the method is supposed to do. Then write your code where it says ""
TODO" to implement the method. You'll do this for each method in the program.
/**
* Removes the specified number (num) of the given element from the
internal ArrayList of elements.
* If num <= 0, don't remove anything.
* If num is too large, remove all instances of the given element
from the internal ArrayList of elements.
* @param num number of instances of element to remove
* @param element to remove
*/
public void remove (int num, int element) {
// TODO Implement method
In addition, you will write unit tests to test your method implementations. Each unit test
method has been defined for you, including some test cases. First make sure you pass all of
the provided tests, then write additional and distinct test cases for each unit test method.
For example, we have defined a "testRemovelnt" method for you (see below) which tests the
"remove" method. Pass the tests provided then write additional tests where it says "// TODO".
You'll do this for each unit test method in the program.
eTest
void testRemoveInt () {
CustomIntegerArrayList arrl - new CustomIntegerArrayList ();
arrl.add (0, 2):
arrl.add (0, 3):
arrl.add (0, 4);
arrl.remove (0):
arrl.remove (1):
Penn
Engineering
TONLINE LEARNING
Introduction to Java & Object Oriented Programming
ArrayList<Integer> 1stl = new ArrayList<Integer> () :
1stl.add (0, 2):
1st1.add (0, 3):
1st1.add (0, 4):
1stl.remove (0) :
1st1.remove (1):
assertEquals (arrl.get (0), 1stl.get (0)):
// TODO write at least 3 additional test cases
The main method calls have been provided for you (see example below). They are designed
purely to call the other methods in the program, and to help you run the program. Nothing
needs to be completed in the main method.
public static void main (String args(]) {
//create new empty CustomIntegerArrayList
CustomIntegerArrayList arrl ="new CustomIntegerArrayList ();
//add element
arrl.add (2):
//get internal arraylist of elements
System.out.printin (arrl.getArrayList ()): //12]
Submission
You have been provided with CustomintegerArrayListjava and
CustomintegerArrayListTest java. To complete the assignment, implement the methods in
CustomintegerArrayList.java, making sure you pass all the tests in
CustomintegerArrayListTest java. Then write at least 3 additional and distinct test cases for
each unit test method in CustomintegerArrayListTestjava. Do not modify the name of the
methods in CustomintegerArral.ist.iava or the automated testina will not recognize it.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- The implementations of the methods addAll, removeAll, retainAll, retainAll, containsAll(), and toArray(T[]) are omitted in the MyList interface. Implement these methods. Use the template at https://liveexample.pearsoncmg.com/test/Exercise24_01_13e.txt to implement these methods this the code i have for the write your own code part import java.util.Iterator; interface MyList<E> extends java.util.Collection<E> { void add(int index, E e); boolean contains(Object e); E get(int index); int indexOf(Object e); int lastIndexOf(E e); E remove(int index); E set(int index, E e); void clear(); boolean isEmpty(); Iterator<E> iterator(); boolean containsAll(java.util.Collection<?> c); boolean addAll(java.util.Collection<? extends E> c); boolean removeAll(java.util.Collection<?> c); boolean retainAll(java.util.Collection<?> c); Object[] toArray(); <T> T[] toArray(T[] a); int size();} and its…arrow_forwardExercise #2 Implement an instance method belonging to the IntArrayBag class that takes two input parameters, oldVal and newVal. The method replaces each oldVal element in the array with newVal. Make sure to include the method header.arrow_forward// Only few methods are mentioned here //Do remaining methods to pass the test methods /*** Removes the specified (num) of the given element from the internal ArrayList of elements. * If num <= 0, don't remove anything. * If num is too large, remove all instances of the given element from the internal ArrayList of elements.* Example:* - For a defined CustomIntegerArrayList containing the integers: 1, 2, 1, 2, 1* - Calling remove(2, 1) would remove the first 2 instances of 1 * - The CustomIntegerArrayList will then contain the integers: 2, 2, 1* - For a defined CustomIntegerArrayList containing the integers: 100, 100, 100 * - Calling remove(4, 100) would remove all instances of 100 * - The CustomIntegerArrayList will then be empty* - For a defined CustomIntegerArrayList containing the integers: 5, 5, 5, 5, 5 * - Calling remove(0, 5) would remove nothing* * @param num number of instances of element to remove * @param element to remove*/ public void remove(int num, int element) {//…arrow_forward
- public class PokerAnalysis implements PokerAnalyzer { privateList<Card>cards; privateint[]rankCounts; privateint[]suitCounts; /** * The constructor has been partially implemented for you. cards is the * ArrayList where you'll be adding all the cards you're given. In addition, * there are two arrays. You don't necessarily need to use them, but using them * will be extremely helpful. * * The rankCounts array is of the same length as the number of Ranks. At * position i of the array, keep a count of the number of cards whose * rank.ordinal() equals i. Repeat the same with Suits for suitCounts. For * example, if your Cards are (Clubs 4, Clubs 10, Spades 2), your suitCounts * array would be {2, 0, 0, 1}. * * @param cards * the list of cards to be added */ publicPokerAnalysis(List<Card>cards){ this.cards=newArrayList<Card>(); this.rankCounts=newint[Rank.values().length]; this.suitCounts=newint[Suit.values().length];…arrow_forwardJava Complete a method calledRedundantCharacterMatch(ArrayList<Character> YourFirstName): the parameter of this method is an ArrayList<Character> whose elements are the characters in your first name (they should be in the order appear in your first name, e.g., if your first name is bob, then the ArrayList<Char> includes ‘b’, ‘o’, ‘b’.). The method will check whether there exists duplicate characters in your name and return the index of those duplicate characters. For example, when using bob as first name, it will return b: 0, 2. 2. Create an ArrayList<Character> NameExample. All the characters of your first name will appear twice in this ArrayList. For example, if your first name is bob, then NameExample will include the following element {b,o,b,b,o,b}. Then, please use NameExample as parameter for the method RedundantCharacterMatch(). If your first name is bob, the results that print in the console will be b: 0, 2, 3, 5 o: 1, 4arrow_forwardGiven that an ArrayList of Strings named friendList has already been created and names have already been inserted, write the statement necessary to change the name "Tyler", stored at index 8, to "Bud". This is needed in Javaarrow_forward
- Java ArrayLists can only be filled with reference type data, so you cannot fill them with primitive type data. How can you work around this with integers? (How can you have an ArrayList filled with integers?)arrow_forwardIn writing a general-purpose sort method in Java, the sort method needs to compareobjects. There are two ways to give the sort method the code to compare objects,implementing the interfaces Comparable and Comparator respectively. Extend Article class toimplement Comparable interface so that the default sorting of the Articles is by its volumearrow_forwardThrough java, have The Delicious class – fields and constructor The class must define and initialise a field of an appropriate collection class to store Chicken objects. There must be no pre-defined limit on the number of Chiciken objects it can store.The Delicious class – basic methodsThe Delicious class must:• Define a method called addChicken that takes a Chicken object as a parameter and adds it to the ArrayList field. Note that this method must not create a Chicken object. Instead, a Chicken object must be passed into it as a parameter value.• Define a method called getNumberOfChickens that returns the number of Chicken objects in the ArrayList.• Define another method also called getNumberOfChickens. This one takes a single parameter of type int representing a price per Kilogram and returns the number of Chicken objects in the collection whose pricePerKilo is less than or equal to the value of the parameter.• Define a method called list that prints out, via System.out, the details…arrow_forward
- IN JAVA. Any help is appreciated! Thank you! PART 1 : Automobiles Create a data class named Automobile that implements the Comparable interface. Give the class data fields for make, model, year, and price. Then add a constructor, all getters, a toString method that shows all attribute values, and implement Comparable by using the year as the criterion for comparing instances. Write a program named TestAutos that creates an ArrayList of five or six Automobiles. Use a for loop to display the elements in the ArrayList. Sort the Arraylist of autos by year with Collections.sort(). Finally, use a foreach loop to display the ArrayList sorted by year.arrow_forwardIf the data is too large to fit in the cache, the CPU will transfer it to main memory, and the write buffer will bring it back. Now what?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education