Question
This is Java problem In this assignment we need to maximize the worth while keeping the weight as what the user wanted so in this
This is Java problem
In this assignment we need to maximize the worth while keeping the weight as what the user wanted so in this case the weight is 100 the most valuabnle item in the backpack we can get is these items. and the worth is 360. Remember if value 0 it can be trown away we need to put the maximum worth first while keeping the weight maximum as we can carry.
This is the driver we cant change the driver.
This is the adventure1 txt input
This is the adventure2 txt input
This is the adventure3 txt input
The output must be the same as above tho dont make our own txt input file
You will model an adventurer delving deep into dungeon ruins to retrieve treasure. Upon entering the treasure after an arduous journey our adventurer is faced with a large pile of loot. You will have to design a back tracking recursive algorithm to find the optimal items to bring home given how much you adventurer can carry and fit in their backpack. Each item will have an associated weight, size and value. The adventurer will have a maximum weight they can carry and a maximum size for their backpack. Item. java Fields (private): name - a string representing the items name weight - an int for the weight of an item value - an int for the value of an item size- and int for the size of an item Constructor: Initializes all fields Methods: Getters for every field, no setters we will be making items immutable tostring - check sample output for format Backpack.java Fields (private): items - an arraylist of item objects that the backpack is "holding" totalWeight - an int, the current total weight of all items in the backpack totalValue - an int, the current total value of all items in the backpack totalSize - an int, the current total size of all items in the backpack maxSize - an int, the maximum size of items in the backpack Constructor: Initializes all fields. Total values should be set to 0, items should be initialized to an empty list and the max size should be set to the maximum size Methods: Getters for every field addItem- insert an item into the item list removeItem- remove an item from the item list checkSpace - checks if an items size will be equal to or less than the maximum size tostring - check sample output for format You will model an adventurer delving deep into dungeon ruins to retrieve treasure. Upon entering the treasure after an arduous journey our adventurer is faced with a large pile of loot. You will have to design a back tracking recursive algorithm to find the optimal items to bring home given how much you adventurer can carry and fit in their backpack. Each item will have an associated weight, size and value. The adventurer will have a maximum weight they can carry and a maximum size for their backpack. Item. java Fields (private): name - a string representing the items name weight - an int for the weight of an item value - an int for the value of an item size- and int for the size of an item Constructor: Initializes all fields Methods: Getters for every field, no setters we will be making items immutable tostring - check sample output for format Backpack.java Fields (private): items - an arraylist of item objects that the backpack is "holding" totalWeight - an int, the current total weight of all items in the backpack totalValue - an int, the current total value of all items in the backpack totalSize - an int, the current total size of all items in the backpack maxSize - an int, the maximum size of items in the backpack Constructor: Initializes all fields. Total values should be set to 0, items should be initialized to an empty list and the max size should be set to the maximum size Methods: Getters for every field addItem- insert an item into the item list removeItem- remove an item from the item list checkSpace - checks if an items size will be equal to or less than the maximum size tostring - check sample output for formatStep 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