due 11/9
Continuing with BetterArray
, implement an insert
method that takes an integer value to insert into the array, and an integer position where to insert it. Make the following test code work.
BetterArray ba; ba.append(7); ba.append(14); ba.append(3); ba.append(-6); ba.print(); // should print [7, 14, 3, -6] ba.insert(5, 1); ba.print(); // should print [7, 5, 14, 3, -6] ba.insert(0, 4); ba.print(); // should print [7, 5, 14, 3, 0, -6]