COP3502 Pakudex Project 3 Solved

35.00 $ 17.50 $

Category:

Description

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.

 

Pouch Creatures – abbreviated “Pakuri” – are the latest craze sweeping elementary schools around the world. Tiny magical creatures small enough to fit into one’s trouser pouches (with enough force applied, ‘natch) have begun appearing all around the world in forests. They come in all shapes colors. When stolen from their parents at a young enough age, they can be kept in small spherical cages (for their own good) easily carried by elementary school children (though they are also popular with adults). This has led to an unofficial catch phrase for the phenomenon – “Gotta steal ‘em all!” – a play on the abbreviation “Pakuri” (which doubles as Japanese slang meaning “to steal”). Young children can then pit their Pakuri against one another in battle for bragging rights or to steal them from one another. (Don’t worry – they heal their wounds quickly!)

 

Of course, keeping track of all these critters can be a real task, especially when you are trying to steal so many of them at such a young age! You’ve decided to cash in – hey, if you don’t someone else will – on the morally ambiguous phenomenon by developing an indexing system – a Pakudex – for kids and adult participants.

Requirements

Students will construct three classes: a driver class with a main() entry point (PakuriProgram) and two data object classes (Pakuri and Pakudex). All attributes / methods must be private unless noted in the specification!

 

Welcome to Pakudex: Tracker Extraordinaire!

Enter max capacity of the Pakudex: 30

The Pakudex can hold 30 species of Pakuri.

 

Pakudex Main Menu

—————–

1.  List Pakuri

2.  Show Pakuri

3.  Add Pakuri

4.  Evolve Pakuri

5.  Sort Pakuri

6.  Exit

What would you like to do?

PakuriProgram Class (Driver / Program)  

When run, the program should…

  • Display a welcome message
  • Prompt for / read Pakudex capacity & confirm
  • Display the menu
  • Prompt for input

 

 

 

Listing Pakuri

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

 

           Success                                                                                       Failure

Pakuri In Pakudex:

1.  Pikaju

2.  Charasaurus

No Pakuri in Pakudex yet!

 

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: PsyGoose

 

Species: PsyGoose

Attack: 65

Defense: 57

Speed: 61

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

Enter the name of the species to add: PsyGoose

Pakuri species PsyGoose successfully added!

 

Pakudex Main Menu

—————–

Enter the name of the species to add: PsyGoose Error: Pakudex already contains this species!
Error: Pakudex is full!

Failure – Full

 

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: PsyGoose PsyGoose 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 speed. All variables storing information about the critters must be private (in accessible from outside of the class). We recommend (but do not mandate) the following variable types and names:

 

String species;

int attack, defense, speed;

 

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

 

Attribute Value
attack (species.length() * 7) + 9
defense (species.length() * 5) + 17
speed (species.length() * 6) + 13

 

(You may have noticed Pakuri don’t have individual names, just species; don’t worry! They won’t live long enough for it to matter with all of the fighting. Your conscience can be clear!)

 

 

The class must also have the following methods and behaviors (this is mandatory):

 

public Pakuri(String species)

This method should be the only constructor for this class. There should not be a default constructor!

 

public String getSpecies()

Returns the species of this critter

 

public int getAttack()

Returns the attack value for this critter

 

public int getDefense()

Returns the defense value for this critter

 

public int getSpeed()

Returns the speed of this critter

 

public void setAttack(int newAttack)

Changes the attack value for this critter to newAttack

 

public void evolve()

Will evolve the critter as follows: a) double the attack; b) quadruple the defense; and c) triple the speed

 

 

Optionally, students may implement the Comparable interface and its methods:

 

public int compareTo(Pakuri target)

Returns integer determining order of this object and target object (see Comparable API for details)

 

We will not test for this method’s proper function; students may implement as desired (if at all) according to design for the rest of the program.

 

Pakudex Class

The Pakudex class will contain all the Pakuri that you will encounter as Pakuri objects. Note: The Pakudex will have a set size determined by user input at the beginning of the program’s run; the number of species contained in the Pakudex will never grow beyond this point.

 

 

The class must also have the following methods and behaviors (this is mandatory):

 

public Pakudex()

Default constructor; if called, the default size for the Pakudex should be 20

 

public Pakudex(int capacity)

Initializes this object to contain exactly capacity objects when completely full

 

public int getSize()

Returns the number of critters currently being stored in the Pakudex

 public int getCapacity()

Returns the number of critters that the Pakudex has the capacity to hold at most

 public String[] getSpeciesArray()

Returns a String array containing the species of the critters as ordered in the Pakudex; if there are no species added yet, this method should return null

 

public int[] getStats(String species)

Returns an int array containing the attack, defense, and speed statistics of species at indices 0, 1, and 2 respectively; if species is not in the Pakudex, returns null

 

public void sortPakuri()

Sorts the Pakuri objects in this Pakudex according to Java standard lexicographical ordering of species name

 

public boolean addPakuri(String species)

Adds species to the Pakudex; if successful, return true, and false otherwise

 

public boolean evolveSpecies(String species)

Attempts to evolve species within the Pakudex; 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:               PakuriProgram.java, Pakuri.java, Pakudex.java

Method:           Submit on ZyLabs