Question: Write a program that will save the Pokemon database to a file so that when you re-run your program any previous changes will be visible.

Write a program that will "save" the Pokemon database to a file so that when you re-run your program any previous changes will be visible. For example:

Here are some hints to get you started:

To begin you will need to move your "starting" dictionary into a file so that it is not "hard coded". This will probably involve figuring out a way to store your data inside of a text file. You can choose to organize your data however you'd like, but something like this might be helpful:

bulbasaur,5,25,grass

charmander,3,100,fire

  • You will need to write a "parser" that will read in this data and transfer it into a dictionary that can be used to drive your program.
  • You will also need to dynamically overwrite this file when a change is made to the database.

Run #1

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit:l

Name Amount Available Adoption Fee Type(s)

Bulbasaur 5 25.00 Grass

Charmander 3 100.00 Fire

Gyrados 1 1,000.00 Water Flying

Squirtle 2 50.00 Water

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit:a

Enter name of new pokemon: pikachu

How many of these Pokemon are you adding?5

What is the adoption fee for this Pokemon?-10

Invalid, please try again

What is the adoption fee for this Pokemon?37.50

Next you will be prompted to enter the 'types' for this Pokemon. Pokemon can have multiple types. Type 'help' to view all possible Pokemon types, and type 'end' to stop entering types. You must enter at least one valid 'type'

What type of Pokemon is this?electric

Type electric applied

What type of Pokemon is this?end

Pokemon added!

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit:l

Name Amount Available Adoption Fee Type(s)

Bulbasaur 5 25.00 Grass

Charmander 3 100.00 Fire

Gyrados 1 1,000.00 Water Flying

Pikachu 5 37.50 Electric

Squirtle 2 50.00 Water

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit:q

See you next time!

Run #2

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit:l

Name Amount Available Adoption Fee Type(s)

Bulbasaur 5 25.00 Grass

Charmander 3 100.00 Fire

Gyrados 1 1,000.00 Water Flying

Pikachu 5 37.50 Electric

Squirtle 2 50.00 Water

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit:q

See you next time!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!