Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Inheritance In Java

Inheritance In Java

Inheritance In Java

Note: This assignment is not written using purely idiomatic Java. It is written as a bridge–transition–between Java and C++.

The next (and last) assignment will add the Tool class and address the non-idiomatic code

1 The Problem

This assignment deals with a program that places items into separate inventories. In this assignment, you will 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 namematerialdurabilityspeedenchantment, and enchantment level. Tool Items are not stackable.

2. The remainder of a Armour line contains–in order–a namematerialdurabilitydefenseenchantmentenchantment level, and element. Armour Items are not stackable.

3. The remainder of a Consumable line contains–in order–a nameeffect, 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 namematerialdurabilityspeedmodifier, and modifier level. Tool Items are not stackable.

2. The remainder of a Armour line contains–in order–a namematerialdurabilitydefensemodifiermodifier level, and element. Armour Items are not stackable.

3. The remainder of a Consumable line contains–in order–a nameeffect, 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 ItemItemStackToolArmour, 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.

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

2 Compiling Java

The easiest way to compile this assignment is to use the ./gradlew command on one of our Linux servers. After that, you will have a number of options for executing the code.

 

If you are installing Java on your own machine, you will need Java 16 or earlier.

As an alternative way to compile your code, you might want to install the Oracle Java compiler and an IDE on your own PC. Eclipse is a recommended platform–

2.1 Compiling and Running the Java Program

If the sample data above is kept in items-01.txt, to run this program, type:

./gradlew jar

java -jar build/libs/Storage.jar src/main/resources/items-01.txt 10

or

./gradlew run

The latter command executes the run target in the Gradle buildfile (which runs the necessary commands for you). This allows us to use fewer keystrokes (which are expensive).

Run the compiled solution with both the provided input file and your own test input files.

Once you have completed your solution, compare the output generated by your solution to the output generated by my solution. The two sets must be identical.

2.2 Compiling and Running the Tests

You should probably run the tests on a Linux machine… You can compile and run the test drivers (TestArmour and TestConsumable) with

./gradlew test

If you implemented everything in Armour and Consumable correctly you will see:

edu.odu.cs.cs330.items.TestConsumable > testClone PASSED

edu.odu.cs.cs330.items.TestConsumable > testCopyConstructor PASSED

edu.odu.cs.cs330.items.TestConsumable > testDefaultConstructor PASSED

edu.odu.cs.cs330.items.TestConsumable > testRead PASSED

edu.odu.cs.cs330.items.TestConsumable > testToString PASSED

edu.odu.cs.cs330.items.TestArmour > testClone PASSED

edu.odu.cs.cs330.items.TestArmour > testCopyConstructor PASSED

edu.odu.cs.cs330.items.TestArmour > testDefaultConstructor PASSED

edu.odu.cs.cs330.items.TestArmour > testRead PASSED

edu.odu.cs.cs330.items.TestArmour > testToString PASSED

in your output. Note that you may see quite a few blank lines in the test summary–I omitted them here for brevity.

If you see FAILED you must revisit revisit the corresponding function(s). There is a mistake in your code.

You may need to run

./gradlew clean test

to force a full recompile after making small updates.

2.3 IDEs and Command Line Arguments

(On a Windows system, you would omit the “./”. If you are running from Code::Blocks or a similar development environment, you may need to review how to  supply command-line parameters  to a running program.) Note that Eclipse provides the option to configure command line arguments.

3 Files

All files for this assignment are in a single zip file inventory_java_1.zip. Extra the contents of this zip file. Do not rename or move any of the files. The directory structure is important.

If you are are using Eclipse, run ./gradlew eclipse from your command prompt, powershell, or terminal (depending on your OS). This command will generate a .project file you can import into Eclipse.

4 Grading

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

In the grade report that you receive, you will see tests numbered 000 through 010.

1. Test 000 evaluates your implementation of Armour.Armour()

2. Test 001 evaluates your implementation of Armour.Armour(Armour src)

3. Test 002 evaluates your implementation of Armour.clone

4. Test 003 evaluates your implementation of Armour.toString

5. Test 004 evaluates your implementation of Armour.read

6. Test 005 evaluates your implementation of Consumable.Consumable()

7. Test 006 evaluates your implementation of Consumable.Consumable(Consumable src)

8. Test 007 evaluates your implementation of Consumable.clone

9. Test 008 evaluates your implementation of Consumable.toString

10. Test 009 evaluates your implementation of Consumable.read

11. Test 010 (System Tests) evaluate all both classes–i.e., your solution as a whole–including output and output formatting.

Do not procrastinate.

5 Submitting

Files to Submit:

· Armour.java–i.e., your version of the Armour ADT.

· Consumable.java–i.e., your version of the Consumable ADT.

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: On Time Writers only hire the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by On Time Writers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. On Time Writers is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At On Time Writers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.