Answered step by step
Verified Expert Solution
Question
1 Approved Answer
user should wright the input(java) Objectives: In this lab, the following topic will be covered: 1. Objects and Classes Task Design a class named Container
user should wright the input(java)
Objectives: In this lab, the following topic will be covered: 1. Objects and Classes Task Design a class named Container to hold items of various weights. The class contains: - An array list of integers to store the weights of items. - The maximum weight (int). - A constructor that constructs a container with specified maximum weight. - A method named addItem that adds an item to the container if it would fit, otherwise it returns false: public boolean addItem(int itemWeight) Write a test program that creates a container with a maximum of 10kg. Your program should prompt the user to enter the weight of an item then adds it to the container. Repeat for a few items. Finally display the contents of the containerStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started