Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Illustrate the compensation structure.

Answered: 1 week ago

Question

Describe the steps in an effective performance management system.

Answered: 1 week ago

Question

Define a performance management system.

Answered: 1 week ago