Starting from:

$40

COP3504C Project 2 -Pakudex Solution

P2: Pakudex


Overview
This project will provide students with practice building and working with object-oriented programming constructs including classes and objects by building classes to represent creatures and a cataloguing system.
Scenario
NOTE: This project concept is a work of satire. To state the obvious: we do not advise one to go around imprisoning creatures in small receptacles held in one’s pockets and/or having them fight for sport.


Requirements
Students will write two files to submit: a main pakudex module (pakudex.py) containing a driver program with the main() function as the entry point and a Pakudex class and a pakuri module (pakuri.py) containing the Pakuri class. All output goes to standard output unless otherwise specified. All attributes / methods must be private unless noted in the specification!

Welcome to Pakudex: Tracker Extraordinaire!

Pakudex Main Menu
-----------------
1. List Pakuri
2. Show Pakuri
3. Add Pakuri
4. Remove Pakuri
5. Evolve Pakuri
6. Sort Pakuri
7. Exit

What would you like to do?
Entry Point
When run as a program, the pakudex module should…

1) Display a welcome message
2) Prompt for input & conduct input error checking
3) Follow the output and formatting in this document
4) Not have print statements in the class method calls
5) Only run main() if invoked directly (i.e., check __name__)
6) Have no global variables

Listing Pakuri
This should number and list the critters in the Pakudex in the order contained. For example, if “Pikarat” and “Charasaurus” were added to the Pakudex (in that order), before sorting, the list should be:

Success Failure
Pakuri in Pakudex:
1. Pikarat
2. Charasaurus No Pakuri currently in the Pakudex!

Pakudex Main Menu

Show Pakuri
The program should prompt for a species and collect species information, then display it:

Success Failure
Enter the name of the species to display: Quacker

Species: Quacker
Level: 15
CP: 286
HP: 45 Enter the name of the species to display: PsyDuck
Error: No such Pakuri!

Pakudex Main Menu
-----------------
1. List Pakuri

Adding Pakuri
When adding a Pakuri, a prompt should be displayed to read in the species name, and a confirmation displayed following successful addition (or failure).

Success Failure – Duplicate
Species: Quackers
Error: Pakudex already contains this species!
Species: Quacker
Level: 15
Pakuri species Quacker (level 15) added!

Pakudex Main Menu -----------------
1. List Pakuri
2. Show Pakuri
Level: -15
Level cannot be negative. Level: NINE-THOUSAND
Invalid level!
Failure – Level


Removing Pakuri
The program should prompt for a species name and then remove the Pakuri if it is in the Pakudex:

Success Failure
Enter the name of the Pakuri to remove: Quacker Pakuri PsyGoose removed. Enter the name of the Pakuri to remove: PsyDuck Error: No such Pakuri!

Evolve Pakuri
The program should prompt for a species and then cause the species to evolve if it exists:

Success Failure
Enter the name of the species to evolve: Quacker Quacker has evolved! Enter the name of the species to evolve: PsyDuck Error: No such Pakuri!

Sort Pakuri
Pakuri have been sorted!
Sort Pakuri in Java standard lexicographical order:

Exit
Thanks for using Pakudex! Bye!
Quit the program:

Pakuri Class
This class will be the blueprint for the different critter objects that you will create. You will need to store information about the critter’s species, attack level, defense level, and stamina. All variables storing information about the critters must be private (inaccessible from outside of the class per Python convention). We recommend (but do not mandate) the following variable types and names:

__species: str
__level, __attack, __defense, __stamina: int

These attack, defense, and speed levels should have the following initial values when first created:

Attribute Value
attack (len(species) * 7 + 11) % 16
defense (len(species) * 5 + 17) % 16
stamina (len(species) * 6 + 13) % 16

While Pakuri attributes are never revealed to the user, they are used (along with level) to determine the combat power (CP) and healthy points (HP), as follows:

𝑯𝑯𝑯𝑯 = 𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹(𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺 × 𝑳𝑳𝑳𝑳𝑳𝑳𝑳𝑳𝑳𝑳 / 𝟔𝟔)


𝑪𝑪𝑯𝑯 = 𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹(𝑨𝑨𝑺𝑺𝑺𝑺𝑺𝑺𝑨𝑨𝑨𝑨 × 𝑫𝑫𝑳𝑳𝑫𝑫𝑳𝑳𝑺𝑺𝑫𝑫𝑳𝑳 × √𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺 × 𝑳𝑳𝑳𝑳𝑳𝑳𝑳𝑳𝑳𝑳 × 𝟎𝟎. 𝟎𝟎𝟎𝟎)


Required Methods
The class must include the following methods exactly as defined:
__init__(self, species: str, level: int)
This method should be the only constructor for this class. There should not be a default constructor!

get_species(self) -> str
Returns the species of this critter

get_attack(self) -> int
Returns the attack value for this critter

get_defense(self) -> int
Returns the defense value for this critter

get_stamina(self) -> int
Returns the speed of this critter

set_attack(self, new_attack: int)
Changes the attack value for this critter to new_attack

Required Properties
These properties must be included as part of the class:
cp (read-only)
Calculates and returns the Pakuri object’s combat power (CP).

hp (read-only)
Calculates and returns the Pakuri object’s health points (HP).

level (read-write)
Gets, or sets, the Pakuri object’s level attribute.
Pakudex Class
The Pakudex class will contain all the Pakuri that you will encounter as Pakuri objects.

Required Methods
The class must include the following methods exactly as defined:
__init__(self)
Default constructor; should prepare a new Pakudex object.

get_species_list(self) -> list[str]
Returns a list of names of the species of the critters as ordered in the Pakudex; if there are no species added yet, this method should return None.

get_stats(self, species: str) -> list[int]
Returns an int list containing the level, CP, and HP of species at indices 0, 1, and 2 respectively; if species is not in the Pakudex, returns None.

sort_pakuri(self)
Sorts Pakuri objects in this Pakudex according to Python standard lexicographical ordering of species name.

add_pakuri(self, species: str, level: int) -> bool
Adds species to the Pakudex; if successful, return True, and False otherwise

remove_pakuri(self, species: str) -> bool
Removes a species from the Pakudex; if successful, return True, and False otherwise

evolve_species(self, species: str) -> bool
Attempts to evolve species within the Pakudex. This should double the Pakuri’s level and increment (increase by one) its attack. If successful, return True, and False otherwise

Submissions
NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission!

Files: pakudex.py, pakuri.py
Method: Submit on ZyLabs

More products