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
icon
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
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!
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
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Randomized Select Algorithm
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education