System zleceń - kopia
This commit is contained in:
68
animals.h
Normal file
68
animals.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
class Animal {
|
||||
protected:
|
||||
std::string name;
|
||||
int age;
|
||||
int size;
|
||||
|
||||
public:
|
||||
// Nested class to represent health-related attributes
|
||||
class HealthStatus {
|
||||
public:
|
||||
bool isHealthy;
|
||||
bool isFed;
|
||||
|
||||
// Constructor to initialize health status
|
||||
HealthStatus(bool healthy = true, bool fed = true);
|
||||
|
||||
// Method to print health status
|
||||
void printHealthStatus() const;
|
||||
};
|
||||
|
||||
// Instance of HealthStatus to track an animal's health
|
||||
HealthStatus healthStatus;
|
||||
|
||||
// Constructor for Animal class
|
||||
Animal(std::string name_input, int age_input, bool isHealthy_input, bool isFed_input, int size_input);
|
||||
|
||||
virtual ~Animal() = default;
|
||||
|
||||
// Getter methods
|
||||
std::string getName() const;
|
||||
int getAge() const;
|
||||
bool getHealthState() const;
|
||||
bool getIsFed() const;
|
||||
|
||||
// Method to print the animal's details
|
||||
void print() const;
|
||||
|
||||
// Pure virtual method for voice, to be implemented by derived classes
|
||||
virtual void voice() = 0;
|
||||
};
|
||||
|
||||
class Lion : public Animal {
|
||||
public:
|
||||
Lion(std::string name_input, int age_input, bool isHealthy_input = true, bool isFed_input = true, int size_input = 100);
|
||||
|
||||
void voice() override;
|
||||
~Lion() override = default;
|
||||
};
|
||||
|
||||
|
||||
class Snake : public Animal {
|
||||
public:
|
||||
Snake(std::string name_input, int age_input, bool isHealthy_input = true, bool isFed_input = true, int size_input = 50);
|
||||
|
||||
void voice() override;
|
||||
~Snake() override = default;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user