Question: Complete the following code in C# and include the following: isEmpty(), isFull(), size(), printAll(), addBack(value), add(value), addFront(value), insert(index), deleteBack(), deleteFront(), delete(index), contains(value), clear(), sort() using

Complete the following code in C# and include the following: isEmpty(), isFull(), size(), printAll(), addBack(value), add(value), addFront(value), insert(index), deleteBack(), deleteFront(), delete(index), contains(value), clear(), sort()

using System;

namespace 2342342

{

class MList

{

private int[] arr;

private int MaxSize;

private int LastElementList = 0;

public MyList(int size)

{

arr = new int[size];

MaxSize = size;

}

public int GetMaxSize()

{

return arr.Length;

}

public void addBack(int value)

{

if (LastElementList == MaxSize)

{

Console.WriteLine("Array is full. Can not add to the list");

}

else

{

arr[LastElementList] = value;

LastElementList++;

}

}

public void printAll()

{

for (int i=0; i< LastElementList; i++)

{

Console.WriteLine(arr[i] + ",");

}

}

}

class Program

{

static void Main()

{

MList arrlist = new MList(50);

int max = arrlist.GetMaxSize();

arrlist.addBack(1);

arrlist.addBack(2);

arrlist.printAll();

Console.WriteLine("My ArrayList has a max of {0} elements", max);

Console.ReadLine();

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!