Home CPSC 240

Inventory System

 

Due: October 1

 

Objective

To get experience working on Java programs combining multiple classes.


 

Task

For this assignment, you will write a program which models the inventory system of a role playing game. In these types of games, players can carry around a set of items called their "inventory".

Each item has a descriptive name, a weight, a value and a strength. The value indicates how much the player could sell the item to a merchant for. The strength only applies to some items (like weapons and armor) and indicates how powerful the item is.

The weight comes into play because the player can only carry a fixed upper limit. If picking up a new item would cause the player to go over their weight limit, then they cannot pick it up (at least until they drop something else).

The system will let the player do the following things:


 

Design

This project will utilize multiple classes. In this case, I am giving you a starting design for the project, which appears below:


 

Details

The UML design above will give you the basic structure of the program. Some notes on implementing this are below:


 

Example Run

Below is an example run to give you an idea of how this can work. Your program doesn't have to work exactly the same way. Also, the items you generate will be different.

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 1
Item Weight Value Strength
Fine Steel Armor 12 19 26
Vase 8 4 0
Fine Steel Short Sword 7 34 21

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 3
Drop an item
1. Fine Steel Armor 12 19 26
2. Vase 8 4 0
3. Fine Steel Short Sword 7 34 21
4. Cancel
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 1
Item Weight Value Strength
Fine Steel Armor 12 19 26
Fine Steel Short Sword 7 34 21

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 2

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 1
Item Weight Value Strength
Fine Steel Armor 12 19 26
Fine Steel Short Sword 7 34 21
Lockpick 8 7 0
Iron Sword 12 16 17
Vase 5 2 0

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 4
Equip a Weapon
1. Fine Steel Short Sword 7 34 21
2. Iron Sword 12 16 17
3. Cancel
: 1

------------------
1. Print inventory
2. Add random item
3. Drop item
4. Equip Weapon
5. Equip Armor
6. Exit
: 6

 

General Requirements

When writing your program, also be sure to:


 

Submitting

To submit your program, email the program file to ifinlay@umw.edu.

Copyright © 2019 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.