This is a continuation of Project 1. In this project, you will add functionality to your Project 1 code to:
read the map data from a text file instead of using hardcoded assignment statements to set up your floor plan.
enable the definition of items that can be found in a room, picked up by the player, carried around in the player's inventory, and dropped in another room.
replace the test code hardcoded into the main program with an interactive user interface, where the player can type in simple one-word or two-word commands to navigate the map and interact with items.
The data file
In this phase of the project, you no longer want to hard-code the room descriptions, as done in Part 1 of the project via the variables room1, room2, room3, ..., room7. Instead, the descriptions of the rooms will be stored in a file called ProjectData.txt.
Start by downloading this file here and storing it on your computer in the same directory/folder as your program. Examine the file.
First, notice that each line in the file contains a series of items separated by commas. Each item is either a string or the word "None". The first seven items correspond to the seven items you saw previously in Project 1: the name of the room, followed by the room you would reach by traveling each of the directions from the current room, in the same order as they appeared in Project 1.
Then notice that some lines have more than seven items. Any additional items in the line represent random objects that can be initially found in that room. For example, the third line in the file looks like:
"Kitchen",None,"Dining Room",None,None,None,None,"cup","fork","knife"
This indicates the name of the room (Kitchen), the door to the east that leads to the dining room, and no other doors. The three additional items at the end indicate that you can find a cup, a fork, and a knife in the Kitchen.
To implement the data file:
Modify the __init()__ method to add a parameter and a property called "contents", which will store the list of objects currently located in that room as a property of the Room object.
Modify the createRoom() method to incorporate this new parameter.
Remove all of the code from the body of loadMap().
Write new code for loadMap(), using the appropriate file operations to read the data from ProjectData.txt and create the seven Roomobjects and the list floorPlan.
The inventory
Modify displayRoom() so that it prints one additional line. After printing all of the neighboring rooms, it should also print "Room contents:", followed by the list of items currently in the room.
The output should look like this:
Room name: Dining Room
Room to the south: Living Room
Room to the west: Kitchen
Room contents: ['plate']
If there are no items in the room, it should look like this:
Room name: Living Room
Room to the north: Dining Room
Room above: Upper Hall
Room contents: []
Modify look() so that, after printing "You are currently in the CURRENTROOM", it also prints the contents of the room.
If there are items in the room, it should look like this:
You are currently in the Kitchen.
Contents of the room:
cup
fork
knife
If there are no items in the room, it should look like this:
You are currently in the Living Room.
Contents of the room:
None
Add a global variable inventory, a list that represents the items the player is carrying. In the main program, initialize it to the empty list.
Add a new function pickup() that attempts to remove an item from the current room and add it to inventory. It takes one parameter, a string representing the item to be picked up. If the item is present in the room, print the message "You now have the ITEM." If the item is not there, print "That item is not in this room."
Add a new function drop() that attempts to remove an item from inventory and add it to the room's contents. It takes one parameter, a string representing the item to be dropped. If the item is in the inventory, print the message, "You have dropped the ITEM." If the item was not in the inventory, print the message, "You don't have that item."
Add a new function listInventory() that shows what the player is currently carrying.
If there are objects in the inventory, the output should look like this:
You are currently carrying:
plate
fork
If there are no items in the inventory, it should look like this:
You are currently carrying:
nothing.
The interactive user interface and expected output
Delete all of the lines in the main program of Project 1 starting with the comment "TEST CODE" and replace it with a command-line interpreter(CLI). A CLI is a block of code that asks the user to enter a command (possibly with arguments), executes code that carries out the purpose of the command, and then asks for another command. It repeats this until the user types in a command that indicates there are no more commands.
The best way to explain what the CLI does is to show you sample interactive output from the program. Below is what appears in a sample run of a working program in the Shell window. Items in red are typed in by the player.
You are currently in the Living Room.
Contents of the room:
None
Enter a command: help
look: display the name of the current room and its contents
north: move north
east: move east
south: move south
west: move west
up: move up
down: move down
inventory: list what items you're currently carrying
get <item>: pick up an item currently in the room
drop <item>: drop an item you're currently carrying
help: print this list
exit: quit the game
Enter a command: north
You are now in the Dining Room.
Enter a command: inventory
You are currently carrying:
nothing.
Enter a command: look
You are currently in the Dining Room.
Contents of the room:
plate
Enter a command: get plate
You now have the plate.
Enter a command: look
You are currently in the Dining Room.
Contents of the room:
None
Enter a command: inventory
You are currently carrying:
plate
Enter a command: exit
Quitting game.
>>>
I included a call to look() before I asked the player to enter the first command. It makes sense to let the player know where he/she is when the game first starts.
When the player enters the command "help", your program should simply print out the text shown above. However, not only does this tell the player what commands exist, this also tells you exactly which commands your CLI must support.
So how do you write this code? Basically, a CLI is code that conforms to the user confirmation pattern we learned earlier this semester!
You ask the user to enter a command.
Start a loop.
The main part of the loop is a big if/elif/else structure that figures out what to do for each possible command. If the command is "look", you make a call to look(). If the command is "get knife", you make a call to pickup("knife"). And so on. Note that some commands (get and drop) take items as arguments, so you need to handle the fact that the command that was input by the player may consist of more than one word.
After executing the command, ask the player to enter another command, and return to the top of the loop.
When the command entered by the player is "Exit", you print the message "Quitting game." and leave the loop. This is the end of your program.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme