Description Feedback In this exercise we'll expand upon the MyArrayList exercise but removing the requirement that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Description Feedback In this exercise we'll expand upon the MyArrayList exercise but removing the requirement that the maximum size of the list be 6. It will still be back with an array, but now the final size of the array can be anything (well, not negative of course). We will also add the ability to remove elements (so the list can get smaller). There are some changes in the details of how the class works, so read the directions carefully. This time, you also start with no data members, so you will have to create your own array (and anything else you need). The main structure of the task however is the same. To complete the task, you will need to complete the following methods: A constructor that accepts nothing (i.e. that has no arguments) that sets up anything that needs to be set up. add (int) - adds a new element to the end of the list. This should always succeed, so we don't need to return anything. int get(int) - returns the value at the specified index position, if the position exists in the list. If not, return 0. Workspace Description Feedback set(int, int) - replace the element at the specified index position with the new value. If the index position doesn't exist in the list, do nothing. size () - return the current size of the list. remove(int) - remove the element at the specified index position. If the position doesn't exist in the list, do nothing. int[] toArray() - return the elements of the list as an array, in the same order. The returned array should have the same length as the size of the list (not the length of the internal array in the class). replace(int, int) - replaces the first occurrence of the first parameter value in the list with the second. Any further occurrences are untouched. boolean contains (int) - returns true if the element is in the list, false otherwise. boolean isEmpty() - returns true if there are no elements in the list, false otherwise. clear() - empties the list. Hint Expand Workspace + MyArrayList.java 1 public class MyArrayList { public MyArrayList() { 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 } public void add(int value) { } public int get(int position) { return -1; } Runner.java public void set(int position, int value) { } public int size() { /home/MyArrayList.java Spaces: 4 (Auto) Console Terminal > [] * All changes saved Run Mark 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 + 36 27 } public int size() { } MyArrayList.java } public void remove(int position) { X } public int[] toArray() { return new int[] {}; return Integer.MIN_VALUE; 2 Runner.java public void replace(int oldValue, int newValue) { public boolean contains (int value) { return false; /home/MyArrayList.java 25:6 Spaces: 4 (Auto) Console Terminal >_ [] * All changes saved Run Mark + 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 } } } MyArrayList.java public void replace(int oldValue, int newValue) { ...LJ } public boolean contains (int value) { return false; return new int[] {}; Runner.java public boolean isEmpty() { return false; } public void clear() { 44 45 46 } /home/MyArrayList.java 25:6 Spaces: 4 (Auto) Console Terminal >_ [] All changes saved Run Mark + MyArrayList.java 1 public class Runner { 2 GAWN 3 4 5} public static void main(String[] args) { //Again, this is just to test things, not part of the assessment } Runner.java /home/Runner.java Spaces: 4 (Auto) Console Terminal > [] * All changes saved Run Mark Description Feedback In this exercise we'll expand upon the MyArrayList exercise but removing the requirement that the maximum size of the list be 6. It will still be back with an array, but now the final size of the array can be anything (well, not negative of course). We will also add the ability to remove elements (so the list can get smaller). There are some changes in the details of how the class works, so read the directions carefully. This time, you also start with no data members, so you will have to create your own array (and anything else you need). The main structure of the task however is the same. To complete the task, you will need to complete the following methods: A constructor that accepts nothing (i.e. that has no arguments) that sets up anything that needs to be set up. add (int) - adds a new element to the end of the list. This should always succeed, so we don't need to return anything. int get(int) - returns the value at the specified index position, if the position exists in the list. If not, return 0. Workspace Description Feedback set(int, int) - replace the element at the specified index position with the new value. If the index position doesn't exist in the list, do nothing. size () - return the current size of the list. remove(int) - remove the element at the specified index position. If the position doesn't exist in the list, do nothing. int[] toArray() - return the elements of the list as an array, in the same order. The returned array should have the same length as the size of the list (not the length of the internal array in the class). replace(int, int) - replaces the first occurrence of the first parameter value in the list with the second. Any further occurrences are untouched. boolean contains (int) - returns true if the element is in the list, false otherwise. boolean isEmpty() - returns true if there are no elements in the list, false otherwise. clear() - empties the list. Hint Expand Workspace + MyArrayList.java 1 public class MyArrayList { public MyArrayList() { 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 } public void add(int value) { } public int get(int position) { return -1; } Runner.java public void set(int position, int value) { } public int size() { /home/MyArrayList.java Spaces: 4 (Auto) Console Terminal > [] * All changes saved Run Mark 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 + 36 27 } public int size() { } MyArrayList.java } public void remove(int position) { X } public int[] toArray() { return new int[] {}; return Integer.MIN_VALUE; 2 Runner.java public void replace(int oldValue, int newValue) { public boolean contains (int value) { return false; /home/MyArrayList.java 25:6 Spaces: 4 (Auto) Console Terminal >_ [] * All changes saved Run Mark + 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 } } } MyArrayList.java public void replace(int oldValue, int newValue) { ...LJ } public boolean contains (int value) { return false; return new int[] {}; Runner.java public boolean isEmpty() { return false; } public void clear() { 44 45 46 } /home/MyArrayList.java 25:6 Spaces: 4 (Auto) Console Terminal >_ [] All changes saved Run Mark + MyArrayList.java 1 public class Runner { 2 GAWN 3 4 5} public static void main(String[] args) { //Again, this is just to test things, not part of the assessment } Runner.java /home/Runner.java Spaces: 4 (Auto) Console Terminal > [] * All changes saved Run Mark
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
You drive 1 2 miles on your way to college campus and it takes' you 2 5 minutes. Before you park your car, you realize that you forgot your wallet. You immediately return home via the same route of 1...
-
Baxter, Inc., has 25,000 shares of $1.35 preferred stock outstanding in addition to its common stock. The $1.35 designation means that the preferred stockholders receive an annual cash dividend of...
-
1. Describe what you understand by a Call Option and a Put Option. 2. During the GFC, the funding of longer-term assets with short-term borrowing was identified as a point of weakness in the...
-
When would you use a motion to strike?
-
Parker is a 100% shareholder of Johnson Corp. (an S corporation). At the beginning of 2010, Parkers basis in his Johnson Corp. stock was $14,000. During 2010, Parker loaned $20,000 to Johnson Corp....
-
I would like to know what is the difference between the Market Return and Daily Stock Return. Is there a formula that we can use based on the historical data of Yahoo Finance for both returns?
-
The information provided in this test allows you to set up the Cieneral, Payables and Receivables ledgers for an Ontario company named CHRIS'S WELDING owned and run by Chris George, amaster welder....
-
Joe has an amount of money X that he would like to invest in some way. He has two options: He can invest the money in an account that pays an annual effective rate of interest of 9%. Joe would...
-
Considering the following excel sensitivity report: .png which one of the following values of the "right hand side" of the third constraint (q3) would modify the current shadow price of this resource...
-
Israel Company provided the following facts regarding pending litigation at year-end: Lawsuit 1: Israel is defending against a lawsuit and believes there is only a 40% chance it will loss in court....
-
Santana Rey has consulted with her local banker and is considering financing an expansion of her business by obtaining a long-term bank loan. Selected account balances at March 31, 2022, for Business...
-
Identify the five most important privacy issues which Amazon company must address as part of its enterprise risk management program. Focus on strategic issues, e.g. lack of management support, lack...
-
Analyze the concept of "the unreliable narrator" in modern literature. What techniques do authors use to create ambiguity, and how does this affect the interpretation of the narrative ?
-
Successful entrepreneurs understand all aspects of business, especially costs and costing systems. In the course project, you will assume the role of the owner of a small business and apply...
-
1. Below is depicted a graph G constructed by joining two opposite vertices of C12. Some authors call this a "theta graph" because it resembles the Greek letter 0. a. What is the total degree of this...
-
Joan is a self-employed attorney in New York City. Joan took a trip to San Diego, CA, primarily for business, to consult with a client and take a short vacation. On the trip, Joan incurred the...
-
Please answer the following questions regarding the taxability of Social Security: a. A 68-year-old taxpayer has $20,000 in Social Security income and $100,000 in tax-free municipal bond income. Does...
-
Laura is a single taxpayer living in New Jersey with adjusted gross income for the 2012 tax year of $35,550. Laura's employer withheld $3,300 in state income tax from her salary. In April of 2012,...
-
A hospitals records show that the cost of carrying out health checks in the last five accounting periods has been as follows: Using the highlow method and ignoring inflation, the estimated cost of...
-
Intermediate: Cost estimation using the linear regression formula. The management accountant at Josephine Ltd is trying to predict the quarterly total maintenance cost for a group of similar...
-
The budget for the production cost of a new product was based on the following assumptions: (i) Time for the 1 st batch of output = 10 hours (ii) Learning rate = 80 per cent (iii) Learning will cease...
Study smarter with the SolutionInn App