You are given the following class definition for an array-based List ADT: public abstract class List { protected int [] m_array; protected int m_index; the array public List (int cap) { m_array = new int [cap]; m index = 0; public abstract int sum (); // underlying array // index of the next open slot in
You are given the following class definition for an array-based List ADT: public abstract class List { protected int [] m_array; protected int m_index; the array public List (int cap) { m_array = new int [cap]; m index = 0; public abstract int sum (); // underlying array // index of the next open slot in
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
![You are given the following class definition for an array-based List ADT:
public abstract class List {
protected int [] m_array;
protected int m_index;
the array
public List (int cap) {
}
m_array = new int [cap];
m index
= 0;
public abstract int sum();
// underlying array
// index of the next open slot in](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F46019e4a-f0f0-48fb-afa2-89c17073743a%2F06520380-3025-4827-bd10-b8812a1dd4e8%2Fa2lwh6u_processed.jpeg&w=3840&q=75)
Transcribed Image Text:You are given the following class definition for an array-based List ADT:
public abstract class List {
protected int [] m_array;
protected int m_index;
the array
public List (int cap) {
}
m_array = new int [cap];
m index
= 0;
public abstract int sum();
// underlying array
// index of the next open slot in
![Follow the steps below to create a concrete class EnhancedList with required
instance variables and methods.
1. Make sure that the EnhancedList class inherits from List.
2. Declare two private instance variables: int m_low and int m_high which
are used in one of the methods you are required to implement.
3. Create a constructor that takes two parameters int cap, int low, and int
high.
4. The constructor should call the constructor of the super class and initialize the
instance variable properly.
5. Create a void method rectify () that verifies if each element is with the
range of [m_low, m_high]. If any element is smaller than m_low, change its
value to m_low. Similarly, if any element is greater than m_high, change its
value to m high.
6. Override the sum method so it computes and returns the sum of the elements
on the list. Note: Don't forget to add the @Override keyword!](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F46019e4a-f0f0-48fb-afa2-89c17073743a%2F06520380-3025-4827-bd10-b8812a1dd4e8%2Fc51mvd4_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Follow the steps below to create a concrete class EnhancedList with required
instance variables and methods.
1. Make sure that the EnhancedList class inherits from List.
2. Declare two private instance variables: int m_low and int m_high which
are used in one of the methods you are required to implement.
3. Create a constructor that takes two parameters int cap, int low, and int
high.
4. The constructor should call the constructor of the super class and initialize the
instance variable properly.
5. Create a void method rectify () that verifies if each element is with the
range of [m_low, m_high]. If any element is smaller than m_low, change its
value to m_low. Similarly, if any element is greater than m_high, change its
value to m high.
6. Override the sum method so it computes and returns the sum of the elements
on the list. Note: Don't forget to add the @Override keyword!
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 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.Recommended textbooks for you

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

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