!!!!!! Create a class for an inventory system for an RPG.(In java)...... Your so
ID: 3840326 • Letter: #
Question
!!!!!!
Create a class for an inventory system for an RPG.(In java)......
Your solution should contain the following classes
An Interface called IContainer - items that implement IContainer can have other things put inside them
Add method - adds an item to the container. You may NOT calculate or store the totals for the container here
TotalCount property - returns how many items are in the container including any containers inside. You MUST calculate the totalCount recursively when this method is called
TotalWeight property - returns the total weight of the container including any containers inside. You MUST calculate the totalWeight recursively when this method is called
A class called Inventory that implements IContainer
The constructor should pass in the number of items in the inventory
An abstract base class called Item
Each item should have a cost and a weight property
Several inherited objects from a typical RPG. Each item should have a different cost and weight
A BagOfHolding class which inherits from Item and implements IContainer
You 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 methods
Explanation / Answer
using System.IO;
using System;
class university
{
}
public interface ITeachable
{
void teach();
}
public interface IAdmin
{
void Administrate();
}
public class dean: ITeachable, IAdmin
{
}
pubic class Professor: ITeachable
{
}
public class ADMINISTRATOR: ITeachable, IAdmin
{
}
public class RESEARCHER: ITeachable
{
enum ResearchSpeciality{R1,R2};
}
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.