Starting from:

$30

COMP1511-Pokedex Assignment Solved

Introduction
For this assignment, we are asking you to implement a mini Pokédex in C. The task is split into 5 sections; each section is not weighted the same.

What is a Pokémon? What is a Pokédex?

Hello there! Welcome to the world of Pokémon! My name is Oak! People call me the Pokémon Prof! This world is inhabited by creatures called Pokémon! For some people, Pokémon are pets. Others use them for fights. Myself ... I study Pokémon as a profession.    — Professor Oak
Pokémon are fictional creatures from the Pokémon franchise, most famously from the Pokémon games. The game revolves around the (questionably ethical) capturing of these creatures. Within the fiction of this universe, a device called the Pokédex is used to catalogue all the creatures a player finds and captures.

Where can we learn more about Pokédexes?

You can play the one of the original Pokémon games here. Quite early in the game you get introduced to the Pokédex.

There's some more information on the Pokémon Wikia.

In addition, Google will be a great resource, as the topic has been extensively written up about.


Supplied Code
This zip file contains the files that you need to get started with the assignment. It contains the following files:

pokedex.h
contains declarations for all functions you need to implement for this assignment. Don't change pokedex.h
pokedex.c
contains stubs for all the functions you need to implement for this assignment. Put all your Pokédex code in pokedex.c.
pokemon.h
contains declarations for all functions you must call to create and manipulate Pokémon. Don't change pokemon.h
pokemon.c
contains the functions you must call to create and manipulate Pokémon. Don't change pokemon.c
main.c
contains a main function and other functions that allow you to interactively test the functions you implement in pokedex.c Don't change main.c
test_pokedex.c
contains a main function and other functions which are your starting point for a test framework to
automatically test the functions you implement in pokedex.c. As you implement functions in pokedex.c you should add tests to test_pokedex.c. Only put testing code in test_pokedex.c.

You can also link and copy the supplied files into your CSE account using commands like these:

 

The ln commands create symbolic links to a file in class account, so you are always using the latest version.


Reference implementation
A reference implementation 1511 pokedex_reference is available to help you understand the assignment.

 

Your pokedex.c (compiled with the supplied pokemon.c and main.c) should match the behaviour of the reference implementation.

Provision of a reference implementation is a common method to provide an operational specification, and it's something you will likely need to do outside UNSW.

If you discover what you believe to be a bug in the reference implementation, report it in the class forum. We may fix the bug or indicate that you do not need to match the reference implementation's behaviour in this case.

Stage 1: Adding and Printing
When you compile and run the given code, you will get the following message if you try to add a Pokemon:

$ dcc -o pokedex main.c pokedex.c pokemon.c 

$ ./pokedex 

===========================[ Pokédex ]========================== 

            Welcome to the Pokédex!  How can I help? 

================================================================ 

Enter command: a 1 Bulbasaur 0.7 6.9 poison grass 

 exiting because you have not implemented the add_pokemon function in poke dex.c

When you run the a command, this function in pokedex.c is called:

 

Your first task is to implement add_pokemon. All the functions you have to implement in pokedex.c have descriptions in pokedex.h:


 

You need to put code in the add_pokemon function to store the pokemon it is given into the pokedex it is given.

You don't need to know any details about what the Pokemon type is (i.e. the type of the Pokemon pokemon argument passed to add_pokemon) to implement add_pokemon or any other function in pokedex.c.

 

If you look in pokedex.h you will discover this definition: typedef struct pokedex *Pokedex In other words the type Pokedex is the same as struct pokedex *.

struct pokedex is defined at the top of pokedex.c.

It already has one field: a pointer to struct pokenode which can be used to store a linked list.

Put in code in add_pokemon to add the pokemon it is given to the linked list whose head is in the pokedex it is given.

Hint: allocate a struct pokenode with malloc.

When you run your code you should see this:

$ dcc -o pokedex main.c pokedex.c pokemon.c 

$ ./pokedex 

===========================[ Pokédex ]========================== 

            Welcome to the Pokédex!  How can I help? 

 
 

================================================================ 

 Enter command: a 1 Bulbasaur 0.7 6.9 poison grass Added Bulbasaur to the Pokedex! 

You'll need to implement 4 more functions to find out if add_pokemon really works:

 

See pokedex.h for information on each function.

detail_pokemon and print_pokemon need to call functions defined in pokemon.h to get the information about a Pokemon they need to print.

Note the information detail_pokemon and print_pokemon print about a Pokemon depends on whether it has been found.

Hint: add a field to struct pokenode to indicate if a Pokemon has been found.

 

 

When all four functions are working you should see something like this:

 

Stage 2: Navigating the List And Destroying the List
For this stage, you are providing the ability to move a cursor through a Pokédex, either stepping through or jumping to a specific pokemon_id. You will also implement the ability to remove a Pokémon from the Pokedex.

 

You must implement these functions in pokedex.c:

 

Again, see pokedex.h for information on what each function should do, and use 1511 pokedex_reference to see what the correct behaviour is.

Note that as time goes on, you may need to update destroy_pokedex to make sure it's cleaning up all the memory in a Pokedex instance. Keep this in mind.

Stage 3: Finding Pokémon
A Pokémon trainer will be venturing out into the wild, meeting and cataloguing Pokémon. These functions will allow you to go exploring and to mark certain Pokémon as "found" in your Pokédex.

For this, you need to complete:

 

Again, see pokedex.h for information on what each function should do, and use 1511 pokedex_reference to see what the correct behaviour is.

Stage 4: Evolutions
What's this? Your Pokédex code is evolving? To finish this evolution of your Pokédex, implement these functions in pokedex.c:

 

Again, see pokedex.h for information on what each function should do, and use 1511 pokedex_reference to see what the correct behaviour is.

Stage 5: Getting Sub-Lists
Set up your Pokédex to do some nice searching!

 

Again, see pokedex.h for information on what each function should do, and use 1511 pokedex_reference to see what the correct behaviour is.


Testing
As you implement functions in pokedex.c, you should add tests to test_pokedex.c .

It already has some basic tests.

 

As usual autotest is available with some simple tests - but your own tests in test_pokedex will be more useful.

 


File Redirection
Every time you run your application, instead of re-typing all the details of each given Pokémon you're adding to the Pokédex, you can store the input for your application in a separate file, and run it using:

 

Then check that your file test1.out contains the correct information given the input file.

A example test1.in might be

 

And the output would be

 


Sample Pokemon

To help you along you can look at a set of 151 add_pokemon commands in sample_pokemon you can use to play around.


Attribution of Work
This is an individual assignment. The work you submit must be your own work and only your work apart from exceptions below. Joint work is not permitted.

You may use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from site such as Stack Overflow or other publically available resources. You should attribute clearly the source of this code in a comment with it.

You are not permitted to request help with the assignment apart from in the course forum, help sessions or from course lecturers or tutors.

Do not provide or show your assignment work to any other person (including by posting it on the forum) apart from the teaching staff of COMP1511.

The work you submit must otherwise be entirely your own work. Submission of work partially or completely derived from any other person or jointly written with any other person is not permitted. The penalties for such an offence may include negative marks, automatic failure of the course and possibly other academic discipline. Assignment submissions will be examined both automatically and manually for such submissions.

Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted you may be penalized, even if the work was submitted without your knowledge or consent. This may apply even if your work is submitted by a third party unknown to you.

More products