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; 1 public List (int cap) ( 1 m_array = new int[cap]; m index - 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 =_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!

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
icon
Concept explainers
Question
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;
1
public List (int cap) (
m array new int[cap];
m index
1
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 n 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 highl. If any element is smaller than - low, change its
value tom low. Similarly, if any element is greater than m high, change its
value to 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 goverride keyword.
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; 1 public List (int cap) ( m array new int[cap]; m index 1 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 n 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 highl. If any element is smaller than - low, change its value tom low. Similarly, if any element is greater than m high, change its value to 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 goverride keyword.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Linked List
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
  • SEE MORE 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