Question: Using data structures from Java Collections is not allowed please implement your own data structures A . Objectives 1 . Use ArrayList to store items

Using data structures from Java Collections is not allowed please implement your own data structures
A. Objectives
1. Use ArrayList to store items in the pantry.
2. Implement methods to add, distribute, and search for items.
3. Ensure the main method does not exceed 30 lines of code.
4. Implement the project correctly.
If you can can you please add meaningful identifiers, consistent indentation, explanatory
comments, and properly formatted output but also explain because I want to learn as much as possible.
B. Description
You are tasked with developing a Food Pantry Management System for a college. This system
will help manage the inventory of a food pantry, allowing items to be added, distributed to
students, and searched.
System Requirements:
1. Pantry Item Management:
- Make a class PantryItem with attributes: name, quantity, and expiryDate.
- Use an ArrayList to store PantryItem objects.
2. Adding Items:
- Implement a method to add items to the pantry. If an item already exists, update
the quantity.
3. Distributing Items:
- Implement a method to distribute items to students. If the requested quantity
exceeds availability, distribute the available quantity and update the inventory.
4. Searching for Items:
- Implement a method to search for items by name. Return the item details if found,
otherwise indicate that the item is not available.
5. User Interface:
- Develop a text-based menu interface to interact with the system. The interface
should include options to add items, distribute items, search for items, and exit the
program.
Edge Cases to Consider:
Adding an item that already exists.
Requesting more items than available.
Searching for items not in the pantry.
Handling invalid inputs gracefully.
Sample Program Flow:
1. Start the program and display the menu.
2. Select an option (Add Item, Distribute Item, Search Item, Exit).
3. Perform the selected action and display the result.
4. Repeat until the user chooses to exit.
Sample Output:
Welcome to the Food Pantry Management System
-------------------------------------------------------
1. Add Item
2. Distribute Item
3. Search Item
4. Exit
Enter your choice: 1
Enter item name: Apples
Enter quantity: 50
Enter expiry date (YYYY-MM-DD): 2024-06-30
Item added successfully!
1. Add Item
2. Distribute Item
3. Search Item
4. Exit
Enter your choice: 2
Enter item name: Apples
Enter quantity: 20
20 Apples distributed successfully!
1. Add Item
2. Distribute Item
3. Search Item
4. Exit
Enter your choice: 3
Enter item name: Apples
Item: Apples, Quantity: 30, Expiry Date: 2024-06-30
1. Add Item
2. Distribute Item
3. Search Item
4. Exit
Enter your choice: 4
Goodbye!

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!