-
Notifications
You must be signed in to change notification settings - Fork 44
КМБО-03-21 Чертков Глеб #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheXlebushek
wants to merge
3
commits into
grayed:master
Choose a base branch
from
TheXlebushek:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,153 @@ | ||
| #include "animal.h" | ||
|
|
||
| using namespace std; | ||
| Animal::Animal() : _massInKilos(20) | ||
| { | ||
| } | ||
|
|
||
| int main() { | ||
| return 0; | ||
| void Animal::setMass(const float& newMass) | ||
| { | ||
| _massInKilos = newMass; | ||
| } | ||
|
|
||
| float Animal::getMass() const | ||
| { | ||
| return _massInKilos; | ||
| } | ||
|
|
||
| std::string Animal::about() const | ||
| { | ||
| return "mass: " + std::to_string(_massInKilos) + "\n"; | ||
| } | ||
|
|
||
| Mammal::Mammal() : Animal(), _amountOfTeeth(20) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void Mammal::setAmountOfTeeth(const float& newAmount) | ||
| { | ||
| _amountOfTeeth = newAmount; | ||
| } | ||
|
|
||
| float Mammal::getAmountOfTeeth() const | ||
| { | ||
| return _amountOfTeeth; | ||
| } | ||
|
|
||
| std::string Mammal::about() const | ||
| { | ||
| return Animal::about() + "amount of teeth: " + std::to_string(_amountOfTeeth) + "\n"; | ||
| } | ||
|
|
||
| Insect::Insect() : Animal(), _amountOfWings(2) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void Insect::setAmountOfWings(const unsigned int& newAmount) | ||
| { | ||
| _amountOfWings = newAmount; | ||
| } | ||
|
|
||
| unsigned int Insect::getAmountOfWings() const | ||
| { | ||
| return _amountOfWings; | ||
| } | ||
|
|
||
| std::string Insect::about() const | ||
| { | ||
| return Animal::about() + "amount of wings: " + std::to_string(_amountOfWings) + "\n"; | ||
| } | ||
|
|
||
| Cat::Cat() : Mammal(), _eyeColor(color::blue) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void Cat::setEyeColor(const Cat::color& newColor) | ||
| { | ||
| _eyeColor = newColor; | ||
| } | ||
|
|
||
| Cat::color Cat::getEyeColor() const | ||
| { | ||
| return _eyeColor; | ||
| } | ||
|
|
||
| std::string Cat::about() const | ||
| { | ||
| return Mammal::about() + "eye color: " + std::to_string((int) _eyeColor) + "\n"; | ||
| } | ||
|
|
||
| Dog::Dog() : Mammal(), _barkVolume(50) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void Dog::setBarkVolume(const float& newVolume) | ||
| { | ||
| _barkVolume = newVolume; | ||
| } | ||
|
|
||
| float Dog::getBarkVolume() const | ||
| { | ||
| return _barkVolume; | ||
| } | ||
|
|
||
| std::string Dog::about() const | ||
| { | ||
| return Mammal::about() + "bark volume: " + std::to_string(_barkVolume) + "\n"; | ||
| } | ||
|
|
||
| Ladybug::Ladybug() : Insect(), _amountOfDots(3) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void Ladybug::setAmountOfDots(const unsigned int& newAmount) | ||
| { | ||
| _amountOfDots = newAmount; | ||
| } | ||
|
|
||
| unsigned int Ladybug::getAmountOfDots() const | ||
| { | ||
| return _amountOfDots; | ||
| } | ||
|
|
||
| std::string Ladybug::about() const | ||
| { | ||
| return Insect::about() + "amount of dots: " + std::to_string(_amountOfDots) + "\n"; | ||
| } | ||
|
|
||
| Bumblebee::Bumblebee() : Insect(), _amountOfLines(10) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void Bumblebee::setAmountOfLines(const unsigned int& newAmount) | ||
| { | ||
| _amountOfLines = newAmount; | ||
| } | ||
|
|
||
| unsigned int Bumblebee::getAmountOfDots() const | ||
| { | ||
| return _amountOfLines; | ||
| } | ||
|
|
||
| std::string Bumblebee::about() const | ||
| { | ||
| return Insect::about() + "amount of lines: " + std::to_string(_amountOfLines) + "\n"; | ||
| } | ||
|
|
||
| std::ostream& operator<<(std::ostream& out, const Animal& animal) | ||
| { | ||
| return out << animal.about() << std::endl; | ||
| } | ||
|
|
||
|
|
||
| int main() | ||
| { | ||
| Bumblebee b; | ||
| std::cout << b; | ||
| return EXIT_SUCCESS; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,119 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <iostream> | ||
|
|
||
| class Animal { | ||
| class Animal | ||
| { | ||
| public: | ||
| float weight; // kg | ||
| void setMass(const float& newMass); | ||
|
|
||
| float getMass() const; | ||
|
|
||
| virtual std::string about() const; | ||
|
|
||
| protected: | ||
| Animal(); | ||
|
|
||
| float _massInKilos; | ||
| }; | ||
|
|
||
| class Mammal : public Animal { | ||
| class Mammal : public Animal | ||
| { | ||
| public: | ||
| float pregnancyDuration; // days | ||
| void setAmountOfTeeth(const float& newAmount); | ||
|
|
||
| float getAmountOfTeeth() const; | ||
|
|
||
| virtual std::string about() const override; | ||
|
|
||
|
|
||
| protected: | ||
| Mammal(); | ||
|
|
||
| unsigned int _amountOfTeeth; | ||
| }; | ||
|
|
||
| class Cat : public Mammal { | ||
| class Insect : public Animal | ||
| { | ||
| public: | ||
| float vibrissaLength; // meters | ||
|
|
||
| void setAmountOfWings(const unsigned int& newAmount); | ||
|
|
||
| unsigned int getAmountOfWings() const; | ||
|
|
||
| virtual std::string about() const override; | ||
|
|
||
| protected: | ||
| Insect(); | ||
|
|
||
| unsigned int _amountOfWings; | ||
| }; | ||
|
|
||
| class Cat : public Mammal | ||
| { | ||
| public: | ||
| enum class color | ||
| { | ||
| grey = 0, yellow, blue, magenta | ||
| }; | ||
|
|
||
| Cat(); | ||
|
|
||
| void setEyeColor(const color& newColor); | ||
|
|
||
| color getEyeColor() const; | ||
|
|
||
| std::string about() const override; | ||
|
|
||
| private: | ||
| color _eyeColor; | ||
| }; | ||
|
|
||
| class Dog : public Mammal | ||
| { | ||
| public: | ||
| Dog(); | ||
|
|
||
| void setBarkVolume(const float& newVolume); | ||
|
|
||
| float getBarkVolume() const; | ||
|
|
||
| std::string about() const override; | ||
|
|
||
| private: | ||
|
|
||
| float _barkVolume; | ||
| }; | ||
|
|
||
| class Ladybug : public Insect | ||
| { | ||
| public: | ||
| Ladybug(); | ||
|
|
||
| void setAmountOfDots(const unsigned int& newAmount); | ||
|
|
||
| unsigned int getAmountOfDots() const; | ||
|
|
||
| std::string about() const override; | ||
|
|
||
| private: | ||
| unsigned int _amountOfDots; | ||
| }; | ||
|
|
||
| class Bumblebee : public Insect | ||
| { | ||
| public: | ||
| Bumblebee(); | ||
|
|
||
| void setAmountOfLines(const unsigned int& newAmount); | ||
|
|
||
| unsigned int getAmountOfDots() const; | ||
|
|
||
| std::string about() const override; | ||
|
|
||
| private: | ||
| unsigned int _amountOfLines; | ||
| }; | ||
|
|
||
| std::ostream& operator<<(std::ostream& out, const Animal& animal); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не сделано: конструкторы, сразу инициализирующие поля.