A C++ console application for managing a simple database of animals (Cat, Coyote, Cow), featuring ASCII art, species-specific sounds, and smart pointer memory management.
- Overview
- Key Features
- Screenshots (Conceptual)
- System Requirements
- Core Custom Header (
animal_ascii.hpp) - Installation and Setup
- Usage Guide
- File Structure
- Technical Notes
- Contributing
- License
- Contact
CritterConsole: Animal Management System, developed by Adrian Lesniak, is a C++ console application designed to manage a simple database of different animal types: Cat, Coyote, and Cow. Users can add new animals by specifying their species, name, and age. The system then allows for displaying all stored animals, each accompanied by its species-specific sound (e.g., "Meow!") and a corresponding ASCII art representation (facilitated by the user-provided animal_ascii.hpp). The program emphasizes good C++ practices, including robust input validation, dynamic memory management using std::unique_ptr for Animal objects, and a clean, menu-driven user interface.
- π
AnimalClass:- Represents individual animals with attributes:
species(Cat, Coyote, Cow - likely an enum or string),name(string), andage(integer, validated range 0β30). addAnimal(likely a static factory method or part ofAnimalManager): Prompts for species, name, and age, performing input validation for age and species choice.makeSound(): A virtual method (or part of a display function) that outputs the species-specific sound and triggers the display of its ASCII art viadisplayAsciiArtfromanimal_ascii.hpp.
- Represents individual animals with attributes:
- π¦
AnimalManagerClass:- Manages a collection of animal records, storing them in a
std::vectorofstd::unique_ptr<Animal>. This ensures automatic and safe memory deallocation when animals are removed or the program exits. addNewAnimal(): Creates a newAnimalobject (based on user input) and adds it to the managed vector.showAllAnimals(): Iterates through the stored animals, displaying their details (species, name, age), invoking theirmakeSound()(or equivalent display logic), and showing their ASCII art.
- Manages a collection of animal records, storing them in a
- π₯οΈ Interactive Console Interface:
- Clear, menu-driven options:
- Add new animal
- Show all animals
- Exit
- Input validation for species selection (1β3) and age input (0β30).
- Clear, menu-driven options:
- π¨ ASCII Art Display: Utilizes a function
displayAsciiArt(const std::string& speciesName)from the user-providedanimal_ascii.hppto render visual representations of a welcome message and each animal type.
Screenshots of: the main menu, the "Add Animal" prompts, and the "Show All Animals" display featuring animal details, their sounds, and their ASCII art.
- Operating System: Any OS supporting a C++11 (or later) compiler (e.g., Windows, Linux, macOS). Console interaction is standard.
- C++ Compiler: A C++ compiler supporting C++11 or later (e.g., g++, clang++, MSVC), as
std::unique_ptrand other modern C++ features are used. - Standard C++ Libraries:
<iostream>,<vector>,<string>,<memory>(forstd::unique_ptr),<limits>(for input validation),<algorithm>(if used for sorting/searching, though not explicitly mentioned for core features). - π
animal_ascii.hppHeader File (User-Provided): This project critically requires a header file namedanimal_ascii.hpp. This file is not included in the repository and must be created by the user. It must define a function likedisplayAsciiArt(const std::string& artName)for rendering ASCII art. See "Core Custom Header" and "Installation and Setup" for details.
The animal_ascii.hpp file is essential for the visual aspect of the program and must be provided by the user. It should contain:
- A function, for example,
void displayAsciiArt(const std::string& artIdentifier);- This function would take a string identifier (e.g., "welcome", "cat", "coyote", "cow") and print the corresponding multi-line ASCII art to the console.
- The ASCII art itself can be defined as multi-line raw string literals or
const char*arrays within this header or a corresponding.cppfile.
Example structure for animal_ascii.hpp:
#ifndef ANIMAL_ASCII_HPP
#define ANIMAL_ASCII_HPP
#include <iostream>
#include <string>
namespace AsciiArt {
inline void displayAsciiArt(const std::string& artName) {
if (artName == "cat") {
std::cout << " /\\_/\\ \n";
std::cout << "( o.o )\n";
std::cout << " > ^ < \n";
} else if (artName == "coyote") {
std::cout << "Coyote Art Here\n";
} else if (artName == "cow") {
std::cout << "Cow Art Here\n";
} else if (artName == "welcome") {
std::cout << "Welcome Art Here\n";
} else {
std::cout << "[No art available for " << artName << "]\n";
}
}
} // namespace AsciiArt
#endif // ANIMAL_ASCII_HPP-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
(Replace
<repository-url>and<repository-directory>with your specific details) -
Create
animal_ascii.hpp: Place youranimal_ascii.hppfile (as described in "Core Custom Header (animal_ascii.hpp)", containing thedisplayAsciiArtfunction and the ASCII art itself) in the project directory. -
Save Main Code: Ensure your main program logic (including the
AnimalandAnimalManagerclass definitions and implementations, and themain()function) is saved asanimal_manager.cpp(or your chosen main file name) in the project directory. (The description implies a single.cppfile for the core classes and main logic). -
Compile the Program: Open a terminal (Command Prompt, PowerShell, Bash, etc.) in the project directory. Example using g++:
g++ animal_manager.cpp -o animal_manager -std=c++11
(Add
-static-libgcc -static-libstdc++on Windows with MinGW if desired for standalone executables. Add optimization flags like-O2for release builds if needed). -
Run the Program:
- On Windows:
or
.\animal_manager.exeanimal_manager.exe
- On Linux/macOS:
(Ensure execute permissions:
./animal_manager
chmod +x animal_manager)
- On Windows:
- Compile and run
animal_manageras detailed above. - Interface:
- The program will display a welcome message (possibly with ASCII art via
displayAsciiArt("welcome")). - A main menu will then appear with the following options:
- Add new animal
- Show all animals
- Exit
- The program will display a welcome message (possibly with ASCII art via
- Input:
- Select a menu option (1, 2, or 3) by typing the number and pressing Enter.
- For "Add Animal" (Option 1):
- You will be prompted to choose the animal species (1 for Cat, 2 for Coyote, 3 for Cow).
- Then, enter the animal's name.
- Finally, enter the animal's age (a number between 0 and 30).
- The program validates species choice and age inputs. Invalid inputs will trigger an error message and prompt for re-entry.
- Output:
- Add Animal: Confirmation of successful addition or an error message.
- Show All Animals (Option 2):
- If no animals are in the database, it will display a message like "No animals in the database!".
- Otherwise, it will iterate through each stored animal and display its:
- Species
- Name
- Age
- Associated ASCII art (via
displayAsciiArt) - Species-specific sound (e.g., "Cat Fluffy (age 3) says: Meow!")
- Actions:
- After operations like "Show all animals," you will likely return to the main menu automatically or after a keypress.
- Select option
3from the main menu to exit the application.
animal_manager.cpp: The main C++ source file containing theAnimalandAnimalManagerclass definitions and implementations, themain()function, and all core program logic.animal_ascii.hpp: (User-provided) Header file responsible for defining and providing thedisplayAsciiArtfunction used to render ASCII art for different animals and potentially a welcome banner.README.md: This documentation file.
(No external data files like .txt or .log are mentioned for this project in the provided description.)
- Smart Pointers (
std::unique_ptr<Animal>): The use ofstd::unique_ptrwithinstd::vectorfor storingAnimalobjects is a modern C++ best practice for managing dynamically allocated memory. It ensures that memory forAnimalobjects is automatically deallocated when they are removed from the vector or when theAnimalManager(and its vector) goes out of scope, preventing memory leaks. - Input Validation: Robust input validation using C++ stream states (
std::cin.fail(),clear(),ignore()) and range checks is crucial for handling incorrect user inputs for species choice and age. - Cross-Platform Design: The core logic is C++ standard and should be cross-platform. Console interactions like
std::coutandstd::cinare standard. Any platform-specific console features (like colored text, if added beyond the description) would need conditional compilation. - ASCII Art Management: The
animal_ascii.hppfile is key for the visual appeal. ThedisplayAsciiArtfunction needs to be flexible enough to handle different species identifiers. - Potential Enhancements:
- Adding more animal species and their corresponding sounds/art.
- Implementing persistent storage for the animal database (e.g., saving to/loading from a file).
- Adding more operations (e.g., edit animal details, remove specific animal, search/filter animals).
- Introducing more complex interactions or behaviors for the animals.
Contributions to CritterConsole: Animal Management System are highly encouraged! If you have ideas for adding new animal types, creating more elaborate ASCII art, implementing data persistence, or enhancing the user interface:
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/YourCritterIdea). - Make your changes and commit them (
git commit -m 'Feature: Implement YourCritterIdea'). - Push to the branch (
git push origin feature/YourCritterIdea). - Open a Pull Request.
Please ensure your code is well-commented, adheres to good C++11 (or later) practices, and maintains a clean and organized structure.
This project is licensed under the MIT License.
(If you have a LICENSE file in your repository, refer to it: See the LICENSE file for details.)
Created by Adrian Lesniak. For questions, feedback, or issues, please open an issue on the GitHub repository or contact the repository owner.
π Bringing a virtual menagerie to your console, one ASCII animal at a time!










