Skip to content

adi1985a/Animal-Management-System

Repository files navigation

πŸΎπŸ–Ό CritterConsole: C++ Animal Management System

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.

License: MIT C++ Platform: Cross-platform

πŸ“‹ Table of Contents

  1. Overview
  2. Key Features
  3. Screenshots (Conceptual)
  4. System Requirements
  5. Core Custom Header (animal_ascii.hpp)
  6. Installation and Setup
  7. Usage Guide
  8. File Structure
  9. Technical Notes
  10. Contributing
  11. License
  12. Contact

πŸ“„ Overview

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.

Demo GIF

✨ Key Features

  • πŸ… Animal Class:
    • Represents individual animals with attributes: species (Cat, Coyote, Cow - likely an enum or string), name (string), and age (integer, validated range 0–30).
    • addAnimal (likely a static factory method or part of AnimalManager): 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 via displayAsciiArt from animal_ascii.hpp.
  • πŸ“¦ AnimalManager Class:
    • Manages a collection of animal records, storing them in a std::vector of std::unique_ptr<Animal>. This ensures automatic and safe memory deallocation when animals are removed or the program exits.
    • addNewAnimal(): Creates a new Animal object (based on user input) and adds it to the managed vector.
    • showAllAnimals(): Iterates through the stored animals, displaying their details (species, name, age), invoking their makeSound() (or equivalent display logic), and showing their ASCII art.
  • πŸ–₯️ Interactive Console Interface:
    • Clear, menu-driven options:
      1. Add new animal
      2. Show all animals
      3. Exit
    • Input validation for species selection (1–3) and age input (0–30).
  • 🎨 ASCII Art Display: Utilizes a function displayAsciiArt(const std::string& speciesName) from the user-provided animal_ascii.hpp to render visual representations of a welcome message and each animal type.

πŸ–ΌοΈ Screenshots (Conceptual)

Screenshots of: the main menu, the "Add Animal" prompts, and the "Show All Animals" display featuring animal details, their sounds, and their ASCII art.

βš™οΈ System Requirements

  • 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_ptr and other modern C++ features are used.
  • Standard C++ Libraries: <iostream>, <vector>, <string>, <memory> (for std::unique_ptr), <limits> (for input validation), <algorithm> (if used for sorting/searching, though not explicitly mentioned for core features).
  • πŸ“„ animal_ascii.hpp Header File (User-Provided): This project critically requires a header file named animal_ascii.hpp. This file is not included in the repository and must be created by the user. It must define a function like displayAsciiArt(const std::string& artName) for rendering ASCII art. See "Core Custom Header" and "Installation and Setup" for details.

🎨 Core Custom Header (animal_ascii.hpp)

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 .cpp file.

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

πŸ› οΈ Installation and Setup

  1. Clone the Repository:

    git clone <repository-url>
    cd <repository-directory>

    (Replace <repository-url> and <repository-directory> with your specific details)

  2. Create animal_ascii.hpp: Place your animal_ascii.hpp file (as described in "Core Custom Header (animal_ascii.hpp)", containing the displayAsciiArt function and the ASCII art itself) in the project directory.

  3. Save Main Code: Ensure your main program logic (including the Animal and AnimalManager class definitions and implementations, and the main() function) is saved as animal_manager.cpp (or your chosen main file name) in the project directory. (The description implies a single .cpp file for the core classes and main logic).

  4. 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 -O2 for release builds if needed).

  5. Run the Program:

    • On Windows:
      .\animal_manager.exe
      or
      animal_manager.exe
    • On Linux/macOS:
      ./animal_manager
      (Ensure execute permissions: chmod +x animal_manager)

πŸ’‘ Usage Guide

  1. Compile and run animal_manager as detailed above.
  2. 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:
      1. Add new animal
      2. Show all animals
      3. Exit
  3. 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.
  4. 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!")
  5. Actions:
    • After operations like "Show all animals," you will likely return to the main menu automatically or after a keypress.
    • Select option 3 from the main menu to exit the application.

πŸ—‚οΈ File Structure

  • animal_manager.cpp: The main C++ source file containing the Animal and AnimalManager class definitions and implementations, the main() function, and all core program logic.
  • animal_ascii.hpp: (User-provided) Header file responsible for defining and providing the displayAsciiArt function 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.)

πŸ“ Technical Notes

  • Smart Pointers (std::unique_ptr<Animal>): The use of std::unique_ptr within std::vector for storing Animal objects is a modern C++ best practice for managing dynamically allocated memory. It ensures that memory for Animal objects is automatically deallocated when they are removed from the vector or when the AnimalManager (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::cout and std::cin are standard. Any platform-specific console features (like colored text, if added beyond the description) would need conditional compilation.
  • ASCII Art Management: The animal_ascii.hpp file is key for the visual appeal. The displayAsciiArt function 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.

🀝 Contributing

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:

  1. Fork the repository.
  2. Create a new branch for your feature (git checkout -b feature/YourCritterIdea).
  3. Make your changes and commit them (git commit -m 'Feature: Implement YourCritterIdea').
  4. Push to the branch (git push origin feature/YourCritterIdea).
  5. 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.

πŸ“ƒ License

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.)

πŸ“§ Contact

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!

About

C++ program for managing animals (Cat, Coyote, Cow) with names and ages. Uses Animal and AnimalManager classes to add animals, display ASCII art, and play sounds. Features input validation and dynamic memory management.

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages