CSE 1320: Intermediate Programming Bonus Assignment 1 solution

$29.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (3 votes)

This bonus assignment focuses on dynamic memory allocation.
Your code must compile without any warnings or errors and run without segmentation
faults to receive credit. Points will be taken for inconsistent formatting.
1. Create a program that implements a basic character sheet with an inventory. User
will be able to create a character, view their info, add items, and view items.
Data Formats
• Item
NAME (char pointer)
PRICE (int)
WEIGHT (double)
• Inventory
ITEMS (Item double pointer)
NUMITEMS (int)
• Character
NAME (char pointer)
LEVEL (int)
XP (long)
INVENTORY (Inventory)
Create a program which allows the user to create a character and add items to their
inventory. The program should utilize a menu that allows the user to
• create a character,
• view their character info,
• add items,
• view their inventory,
• and exit the program.
Requirements
• When creating a character, check if the character pointer is NULL. A character
can only be created if one does not already exist.
• The create character function should take a single input which is Character *.
CSE 1320: Bonus Assignment 1 Dillhoff
• The view character function should take as input Character * and list the
character information as shown in the example run. If a character has not
been created, tell the user to create a character first.
• The add item function should take as input Inventory *. Make sure to reallocate the memory to accommodate the additional item.
• The view item function should take as input Inventory and list all items as
shown in the example run. If there are no items, tell the user that their bag is
empty.
• Make sure to free all memory that is allocated.
Your menu and output should resemble the example run below.
Example Run
C Create Character
V View Character
A Add Item
I View Items
Q Quit
> C
Enter name: Grog Strongjaw
Enter level: 20
Enter XP: 10000
C Create Character
V View Character
A Add Item
I View Items
Q Quit
> V
Grog Strongjaw, level 20 with 10000 XP.
C Create Character
V View Character
A Add Item
I View Items
Q Quit
> A
Enter name: Great Axe
Enter price: 1000
Enter weight: 10.3
C Create Character
V View Character
A Add Item
I View Items
Q Quit
> I
Greate Axe, 1000 gold, 10.3 pounds.
C Create Character
V View Character
A Add Item
2
CSE 1320: Bonus Assignment 1 Dillhoff
I View Items
Q Quit
> Q
Save your code as charsheet.h and charsheet.c.
Create a zip file using the name template LASTNAME_ID_BA1.zip which includes the all
required code files. Submit the zip file through Canvas.
3