Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

=+What would happen to wages?

Answered: 1 week ago

Question

Comment should this MNE have a global LGBT policy? Why/ why not?

Answered: 1 week ago