Lab 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Lab - 2

Problem 1: Define a Basic List Structure with Constructors

● Objective: Create a basic structure for a list with constructors.


● Task: (0.5 point)
● Define a class CustomList<T>.
● Add a private array to hold elements.
● Implement a default constructor and a constructor that takes an
initial size.

Problem 2: Add Element Addition Capability and Get Method

● Objective: Implement the ability to add and retrieve elements from your
list.
● Task: (0.5 point)
● Implement a method Add(T item) that adds an item to the list.
● Add a Get(int index) method to retrieve an item at a specific index.

Problem 3: Implement Indexer

● Objective: Provide direct access to elements in the MyList class.


● Task: (0.5 point)
● Implement an indexer that allows getting and setting values at
specific indexes with bounds checking.

Problem 4: Implement IndexOf and Contains

● Objective: Enable searching for elements within the MyList class.


● Task: (0.5 point)
● Implement IndexOf to return the index of a specified item.
● Implement Contains to check if a specified item exists in the list.

Problem 5: Implement a Custom Array Copy Method

● Objective: Create a manual method for copying array elements.


● Task: (0.5 point)
● Develop a method that copies elements from one array to another
up to a specified count.
Problem 6: Implement RemoveAt and Remove

● Objective: Allow elements to be removed from the MyList class by index


or value.
● Task: (0.5 point)
● Implement RemoveAt to remove an item at a specified index.
● Implement Remove to remove the first occurrence of a specified
item.

Problem 7: Implement Clear and Reverse

● Objective: Add functionality to reset the list and reverse the order of
elements.
● Task: (0.5 point)
● Implement Clear to reset the list and its capacity.
● Implement Reverse to reverse the order of the elements in the list.

Problem 8: Implement Insert

● Objective: Allow insertion of elements at a specific index within the


MyList class.
● Task: (0.5 point)
● Implement Insert to add an item at the specified index, shifting
other elements as needed.

Problem 9: Override ToString

● Objective: Provide a string representation of the MyList class's contents.


● Task: (0.5 point)
● Override the ToString method to return a string that lists all the
elements in the MyList.

Problem 10: Implement Sort

● Objective: Add sorting functionality to the MyList class.


● Task: (0.5 point)
● Implement Sort to order the elements in the MyList.

You might also like