java2

 

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 typethe remainder of the line varies by item type.

Tool Pickaxe Diamond 100 1 Fortune 5
Tool Shovel Gold 20 3 Unbreaking 2
Tool Pickaxe Diamond 100 1 Fortune 5
Potion Speed-II-Potion Spd*2 1
Food Tomato Hunger-10 2
Disposable PotatoCamera ImageQuality-97% 5
Disposable PotatoCamera ImageQuality-97% 5
Tool Axe Stone 10 2 Unbreaking 2
Armour Boots Diamond 100 10 Protection 3 lightning
Armor Boots Diamond 100 10 FeatherFalling 4 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 containsin ordera name, material, durability, speed, modifier, and modifier level. Tool Items are not stackable.
  2. The remainder of a Armour line containsin ordera name, material, durability, defense, modifier, modifier level, and element. Armour Items are not stackable.
  3. The remainder of a Consumable line containsin ordera name, effect, and # uses. Consumable Items are stackable.

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

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

 

2 Output

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

Processing Log:
(S) Pickaxe
(S) Shovel
(S) Pickaxe
(S) Speed-II-Potion
(S) Tomato
(S) PotatoCamera
(S) PotatoCamera
(S) Axe
(S) Boots
(S) Boots

Player Storage Summary:
-Used  90% of 10 slots
 Nme: Pickaxe
 Dur: 100
 Spd: 1
 Mtl: Diamond
 Mdr: Fortune (Lvl 5)

 Nme: Shovel
 Dur: 20
 Spd: 3
 Mtl: Gold
 Mdr: Unbreaking (Lvl 2)

 Nme: Pickaxe
 Dur: 100
 Spd: 1
 Mtl: Diamond
 Mdr: Fortune (Lvl 5)

 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: Axe
 Dur: 10
 Spd: 2
 Mtl: Stone
 Mdr: Unbreaking (Lvl 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

Your outputincluding labels and spacingmust match the expected output.

 

3 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.

You have a few tasks to complete. First, start with 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.

The first few tasks should be familiarthey were your tasks in . You will then need to complete:

  1. Armour.equals
  2. Armour.hashCode
  3. Consumable.equals
  4. Consumable.hashCode

The rules for computing hash codes and checking for equivalence are listed the Javadoc comments (i.e., in comments before the function).

 

Adding the Tool Class

Your final set of tasks involve completing the Tool class.

  1. Complete the Tool Constructor.
  2. Complete the Tool Copy Constructor.
  3. Complete the Tool clone method.
  4. Complete the Tool read method.
  5. Complete the Tool toString method.
  6. Complete the Tool equals method.
  7. Complete the Tool hashCode method.