Question: 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 topicuser 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 container

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!