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
-
In 6-8 find the velocity v(t) and position s(t) at time t> 0 of a material particle that moves without friction along a straight line, when its acceleration, initial position, and initial velocity...
-
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...
-
(a) Prove that z = ()2. (b) Prove that if n is a positive integer, then z = ()n.
-
Consider the variation of the Ehrenfest urn model of diffusion studied in Section 10.1, Exercise 33, where one of the 2k molecules is chosen at random and is then moved between the urns with a fixed...
-
A \(60 \mathrm{vol} \%\) tributyl phosphate (TBP) in kerosene solvent extracts \(\mathrm{Zr}\left(\mathrm{NO}_{3} ight)_{4}\) from an aqueous solution. Entering solvent is recycled from a solvent...
-
All-A-Buzz makes three products from a joint production process using honey. Joint cost for the process in 2010 is $123,200. Each container of honey butter, jam, and syrup, respectively, contains 16...
-
Question 24 ETF Beta Standard Deviation Sharpe Ratio Alpha R-squared Sortino Treynor A .8 25% 2.4 5% 55% .45 4.23 B 1.4 15% 2.2 7% 70% .33 3.12 You are most concerned with tracking the benchmark...
-
Kinkaid Co. is incorporated at the beginning of this year and engages in a number of transactions. The following journal entries impacted its stockholders equity during its first year of operations....
-
1. Cost Reductions: Metric: Percentage of Cost Savings Calculation : (Total Cost Savings / Total Procurement Spend) times 100 is the calculation. How: To calculate the cost savings obtained, compare...
-
Do size and value effects mean that small stocks outperform large stocks or value stocks outperform growth stocks in every year/every month? Explain.
-
Calculate approximately how far the shoes traveled betweenCalifornia and Hawaii. They traveled around 2,000mi betweenCalifornia and Hawaii. Considering the distance you figured in #6, and the time...
-
Assume that due to staff shortages, two junior cyber security technicians have been assigned responsibilities above their expertise level. They are happy with the new job but concerned about their...
-
Exercise 12-8A (Algo) Determining cash flow from investing activities LO 12-3 On January 1, Year 1, Shelton Company had a balance of $271,000 in its Land account. During Year 1, Shelton sold land...
-
Please create the model of a library database. Describe the one-to-many relationships in the library database What is the name of the DDL file you exported in step 2.3 Generate DDL ? Create a...
-
(10 points) The following pseudocode counts the number of digits in a number. READ number SET counter TO 0 WHILE number > 0 ADD 1 TO counter COMPUTE number AS number / 10 ENDWHILE DISPLAY counter Let...
-
On July 1, 2011, Flashlight Corporation sold equipment it had recently purchased to an unaffiliated company for $480,000. The equipment had a book value on Flashlights books of $390,000 and a...
-
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,...
-
Visit the Information Systems Audit and Control Associations (ISACA) Web site (www.isaca.org) to review the COBIT framework (version 4.1). Complete the following matrix to show how the 34 high-level...
-
Taibert Corporation hired an independent computer programmer to develop a simplified payroll application for its newly purchased computer. The programmer developed an online data entry system that...
-
Which of the following is not a reason an internal auditor should participate in internal control reviews during the design of new systems? a. It is more economical to design controls during the...
Study smarter with the SolutionInn App