Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following interface: public interface KnapsackItem public int aetwelahtO public int aetValue) Write a GoldRing class that makes use of the interface. Include a

image text in transcribed

Consider the following interface: public interface KnapsackItem public int aetwelahtO public int aetValue) Write a GoldRing class that makes use of the interface. Include a toStrinal method to report the name of the item (Gold Ring), its value, and its weight. Call the interface methods from the taStrina) method. (10 points) public int compare(Object o1, Object o2); Write a Comparator called CompareKnapsackItems. The constructor accepts a boolean to determine whether the individual Knapsackltems should be compared by value (true) or by weight (false) in ascending order in either case. Use proper generics wherever appropriate. (15 points) Write a KnapsackItems class that has-a List to store a collection of items that use the Knapsackltem interface. The constructor (5 points) takes an integer that specifies the max.weight (if maxweight is invalid, throw a KnapsackException). Assume a ListFactory exists to create the List for you. Use proper generics wherever appropriate. Complete the following four methods in the Knapsackltems class plus the constructor. Use the provided blank page. Assume KnapsackException exists as a RuntimeException. O. Provide thorough javadoc documentation for the addItem method (preconditions, postconditions, and throws) (10 points)

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

1. Television more Over watching faceing of many problems ?

Answered: 1 week ago

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago