top of page
np.jpg

Array List Management

 Overview 

This project was created as a programming exercise to practice C++ object-oriented programming. To handle numeric data, verify user input, show stored values, and carry out element-wise addition between two lists, I developed a new ArrayList class. By creating a reusable data structure from scratch, this exercise improved my comprehension of classes, arrays, encapsulation, loops, and algorithm creation.

Tools and Technologies Used

  • C++

  • Object-Oriented Programming (OOP)

  • Arrays

  • User Input Validation

  • Functions and Methods

  • Console-Based Application Development

Key Steps 

1. Designed the ArrayList Class

To handle numeric data, I first created a new ArrayList class. The class has a variable that keeps track of how many items are presently stored as well as a fixed-size array that can hold up to 20 elements. I was able to learn encapsulation and develop a reusable structure that could be applied throughout the application by grouping the data and functionality under a class.


2. Implemented Data Management Functions

I created a number of member functions to handle the list data after building the class structure. The application was able to show stored values, modify the list's size, take user input, and retrieve specific elements as needed thanks to these capabilities. Object-oriented design concepts were strengthened and code organization was enhanced by separating these operations into dedicated methods.


3. Added Input Validation

I used input validation to make sure the user supplied a valid number of elements after the fundamental functionality was established. The program determines whether the user input is within the permitted range before proceeding because the array was restricted to a maximum of 20 values. This enhanced the program's dependability and gave users experience dealing with possible mistakes.


4. Created and Populated Multiple Lists

I made two distinct ArrayList objects and gave them the user-specified size after verifying the data. After asking the user to enter values for each list separately, the application uses the class methods to store the data. I was able to experience working with several objects made from the same class while keeping distinct sets of data thanks to this step.


5. Displayed Stored Data

Once both lists were populated, I used the class display functions to print the contents of each list in a readable format. Displaying the stored values allowed users to verify their input and ensured that the data had been stored correctly before any calculations were performed.


6. Performed Element-Wise Addition

I used logic to determine the total number of matching elements from both lists after verifying that the data was recorded accurately. The software retrieves data from each list and outputs the resulting sums using a loop and the class accessor method. My knowledge of array traversal, object interaction, and fundamental algorithm building was strengthened by this phase.


PUT ALL TOGETHER

Note: To view the complete code and run it, scroll down within the box if the code appears to be shrinking.

Analysis and Conclusion

This project effectively illustrated the efficient organization and processing of data in C++ using object-oriented programming. I was able to incorporate features for user input, validation, data retrieval, and element-wise calculations while keeping data storage and program logic apart by creating a bespoke ArrayList class.

 

Learning how classes can enhance code reusability and streamline program organization was one of the exercise's most beneficial features. In order to make the program easier to read, maintain, and grow, I developed methods that handled particular tasks rather than storing and modifying data directly within the main function.

 

Additionally, the project reaffirmed basic programming ideas including loops, arrays, input validation, and object interaction. The application offers hands-on experience creating a custom data structure and using object-oriented programming concepts to address an issue in an organized and scalable manner, even if it carries out a rather straightforward task.

bottom of page