Item inventory inheritance c++ | Computer Science homework help


1 The Problem

This assignment deals with a program places items into separate inventories.

In this assignment, you will make use of inheritance–e.g., virtual functions. You will need to 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 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. The easiest way to see generate the expected output is to run the sample executable solution I have provided.

Hint – each line of output in your display functions should probably start with two leading spaces.

To run this program with items-01.txt as input type:

./storage items-01.txt

(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.)

1.3 Your Tasks

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

Your overall task is to complete the Armour and Consumable ADTs.

  1. As an initial step, you will need to complete the Armour and Consumable Default Constructors:
    1. Set the stackable attribute–i.e., stackable.
      Hint Remember initializer lists?
    2. Set the name attribute–i.e., Item::name. The attribute, name, is a protected data member of Item.
  2. Implement Armour::clone and Consumable::clone.
  3. Implement Armour::read and Consumable::read.
  4. Implement Armour::display and Consumable::display.

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

1.3.1 Expected Initial Error Messages

If you run make without adding the missing read, clone, and display methods, you will see something simliar to

/usr/bin/ the vtable symbol may be undefined because the class is missing its key function
Armour.cpp:14: error: undefined reference to 'vtable for Armour'
/usr/bin/ the vtable symbol may be undefined because the class is missing its key function
Consumable.cpp:4: error: undefined reference to 'vtable for Consumable'
/usr/bin/ the vtable symbol may be undefined because the class is missing its key function
Consumable.cpp:12: error: undefined reference to 'vtable for Consumable'
/usr/bin/ the vtable symbol may be undefined because the class is missing its key function
collect2: error: ld returned 1 exit status
make: *** [storage] Error 1

While these errors may be intimidating, they are simply telling you to implement the necessary virtual functions for Armour and Consumable.

1.3.2 Testing Your Code

I have provided you a set of unit tests. In addition to your normal checks (e.g., running the completed program and performing head-to-head testing) run the unit tests with

make tests

You should see:

PASSED -> testDefaultArmourConstructor
PASSED -> testArmourCopyConstructor
PASSED -> testArmourClone
PASSED -> testArmourDisplay
PASSED -> testArmourRead
PASSED -> testDefaultConsumableConstructor
PASSED -> testConsumableCopyConstructor
PASSED -> testConsumableClone
PASSED -> testConsumableDisplay
PASSED -> testConsumableRead

2 Grading

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

  1. Test 000 evaluates your implementation of Armour::Armour()
  2. Test 001 evaluates your implementation of Armour::clone()
  3. Test 002 evaluates your implementation of Armour::display
  4. Test 003 evaluates your implementation of Armour::read
  5. Test 004 evaluates your implementation of Consumable::Consumable()
  6. Test 005 evaluates your implementation of Consumable::clone()
  7. Test 006 evaluates your implementation of Consumable::display
  8. Test 007 evaluates your implementation of Consumable::read
  9. Test 008 (System Test) evaluates all both classes–i.e., your solution as a whole–including output and output formatting.

Do not procrastinate.

3 Files

See Attachment 

4 Submitting

Files to Submit:

  • Armour.cpp–i.e., your version of the Armour ADT.
  • Consumable.cpp–i.e., your version of the Consumable ADT.
Academic Brigade
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.


Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.


Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.


Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.


Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.