Question: Files and the rest of the program is shared in this google drive link ( https://drive.google.com/file/d/1rn7RjpKcvcow6SHQrMMclJ0FIMSQj3Wo/view?usp=sharing ) This assignment deals with a program that places


Files and the rest of the program is shared in this google drive link


( https://drive.google.com/file/d/1rn7RjpKcvcow6SHQrMMclJ0FIMSQj3Wo/view?usp=sharing )

This assignment deals with a program that places items into separate inventories. This is similar to placing items into chests in Minecraft. This assignment is similar to Assignment 1, Assignment 2 and Assignment 4. In this assignment, U wll once again make use of inheritance-e.g., virtual functions. This time... in Java.

You will complete the Armour and Consumable classes.

1.1 Input

The program reads data from one file, items-0x.txt. Each line in this file represents one item. The first item on every line denotes the Item type-the remainder of the line varies by item type.

 Tool Pickaxe Diamond 100 1 Fortune 5 Potion Speed-II-Potion Spd*2 1 Food Tomato Hunger-10 2 Tool Axe Stone 10 2 Unbreaking 2 Armour Boots Diamond 100 10 Protection 3 lightning 

Each Item type is denoted by a keyword:

  • Tool indicates a Tool object.
  • Armour and Armor indicate an Armour object.
  • Food, Potion, and Disposable indicate a Consumable object.

After the leading keywords, each line has a distinct structure:

  1. The remainder of a Tool line contains-in order-a name, material, durability, speed, enchantment, and enchantment level. Tool Items are not stackable.
  2. The remainder of a Armour line contains-in order-a name, material, durability, defense, enchantment, enchantment level, and element. Armour Items are not stackable.
  3. The remainder of a Consumable line contains-in order-a name, effect, and # uses. Consumable Items are stackable.

1.2 Input

The program reads data from one file, items-0x.txt. Each line in this file represents one item. The first item on every line denotes the Item type-the remainder of the line varies by item type.

 Tool Pickaxe Diamond 100 1 Fortune 5 Potion Speed-II-Potion Spd*2 1 Food Tomato Hunger-10 2 Tool Axe Stone 10 2 Unbreaking 2 Armour Boots Diamond 100 10 Protection 3 lightning 

Each Item type is denoted by a keyword:

  • Tool indicates a Tool object.
  • Armour and Armor indicate an Armour object.
  • Food, Potion, and Disposable indicate a Consumable object.

After the leading keywords, each line has a distinct structure:

  1. The remainder of a Tool line contains-in order-a name, material, durability, speed, modifier, and modifier level. Tool Items are not stackable.
  2. The remainder of a Armour line contains-in order-a name, material, durability, defense, modifier, modifier level, and element. Armour Items are not stackable.
  3. The remainder of a Consumable line contains-in order-a name, effect, and # uses. Consumable Items are stackable.

In each of the above classes, you will need to:

  1. Set the stackable attribute-i.e., super.stackable. The attribute, stackable, is a private data member of Item.
  2. Set the name attribute-i.e., super.name. The attribute, name, is a protected data member of Item.

1.3 Output

If the program is run with the first provided input file, items-01.txt, the following output should be generated:

Processing Log: (S) Speed-II-Potion (S) Tomato (S) PotatoCamera (S) PotatoCamera (S) Boots (S) Boots Player Storage Summary: -Used 50% of 10 slots Nme: Speed-II-Potion Eft: Spd*2 Use: 1 Qty: 1 Nme: Tomato Eft: Hunger-10 Use: 2 Qty: 1 Nme: PotatoCamera Eft: ImageQuality-97% Use: 5 Qty: 2 Nme: Boots Dur: 100 Def: 10 Mtl: Diamond Mdr: Protection (Lvl 3) Emt: lightning Nme: Boots Dur: 100 Def: 10 Mtl: Diamond Mdr: FeatherFalling (Lvl 4) Emt: lightning 

Note how there is no Tool output. The Tool class is not present in this assignment. The Tool class will be part of a future assignment.

Your output-including labels and spacing-must match the expected output.

1.4 Your Tasks

The key abstractions employed in this program are Inventory Item, ItemStack, Tool, Armour, and Consumable.

Do not change the packages. The package must remain package edu.odu.cs.cs330.items; for Tool, Armour, and Consumable. Changing the package is an automatic fail. Is this strict? Absolutely. However, I am explicitly instructing you to use this package.

Your task is to finish the Armour and Consumable ADTs:

  1. Complete the Default Constructor for each class.
  2. Complete the Copy Constructor for each class.
  3. Complete the clone method for each class.
  4. Complete the read method in each class.
  5. Complete the toString method in each class.

Note that I have provided stubs for each of these functions (i.e., the code will compile). However, until you complete these functions, the code will not generate meaningful output.

If you are careful, you will notice that I have left notes in some of these functions. These are hints.

Refer to the recorded Review Discussions & Example Code.

You are expected to generate additional input files to test your code. Test your code throughly before submitting your solution.


The Rest is with the full doc in the google drive


( https://drive.google.com/file/d/1rn7RjpKcvcow6SHQrMMclJ0FIMSQj3Wo/view?usp=sharing )

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer Heres a brief example of how you might implement these methods in the Armour class package ed... View full answer

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 Programming Questions!