[Solved] Create a class for an inventory system for an RPG

$25

File Name: Create_a_class_for_an_inventory_system_for_an_RPG.zip
File Size: 461.58 KB

SKU: [Solved] Create a class for an inventory system for an RPG Category: Tag:
5/5 - (1 vote)

Create a class for an inventory system for an RPG.Your solution should contain the following classesAn Interface called IContainer items that implement IContainer can have other things put inside them Add method adds an item to the containerTotalCount property returns how many items are in the container including any containers insideTotalWeight property returns the total weight of the container including any containers insideA class called Inventory that implements IContainer The constructor should pass in the number of items in the inventoryAn abstract base class called Item Each item should have a cost and a weight propertySeveral inherited objects from a typical RPG. Each item should have a different cost and weightA BagOfHolding class which inherits from Item and implements IContainerYou should write some test code to test all of your classes. For example it might look something like this. Make sure that you test the recursive TotalCount and TotalWeight methodsvar inventory = new Inventory(3);inventory.Add(new Sword());inventory.Add(new Potion());var bagOfHolding = new BagOfHolding(4);inventory.Add(bagOfHolding);bagOfHolding.Add(new Sword());Console.WriteLine( The number of items in the inventory is {0} , inventory.TotalCount); //There are 5 items in this exampleConsole.WriteLine( The total weight of the inventory is {0} , inventory.TotalWeight); //Weight will depend on the weights of each item

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Create a class for an inventory system for an RPG
$25