Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

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.
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education