Question
C++ program, can you help me finish this code _use binary search for pet _get random numLimbs between 0, 2, 4, 8 // A Pet
C++ program, can you help me finish this code
_use binary search for pet
_get random numLimbs between 0, 2, 4, 8
// A Pet Class and its driver #include
// Pet class with a name, id, numLimbs. // Also has a static population member. class Pet { private: string name; long id; int numLimbs; // static int population = 0; public: // Ctrs Pet(); Pet(string name, long id, int numLimbs);
// Getters or Accessors long getID() const; string getName() const; int getNumLimbs() const; // Setters or Mutators bool setID(long id); bool setName(string name); bool setNumLimbs(int numLimbs) { this->numLimbs = numLimbs; } // Serialization string to_string() const; // E.g. Returns "Pet: ufomo. ID: 1024; number of Limbs: 8" };
// Global function to generate a cool sounding name by picking // consonants and vowels in alternate fashion. string makeCoolName(int len) { // Your code from before goes here. return "A. Cool. Name"; }
// In this main driver, we initialize an array of STORE_SIZE Pets // Assign them random values, and enter a user interaction loop // in which the user types in a desired ID, and the system will // search the store for a pet with the ID and print its details. int main() { const int STORE_SIZE = 10*1000; // Declare an array of pets Pet pets[STORE_SIZE]; // Loop over the pets to initialize each Pet // Enter a user interaction loop in which we // - prompt the user for an ID // - Scan the array of pets (my pet store) for a Pet with that ID // - If found, print the details of the pet // - If not found, say "No such pet exists in this store" or equiv. message // - If the user entered 0 or a negative number in his/her ID search, exit gracefully.
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started