-
Notifications
You must be signed in to change notification settings - Fork 45
КМБО-03-21 Мочалов Георгий #42
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
Need2BuySSD
wants to merge
5
commits into
grayed:master
Choose a base branch
from
Need2BuySSD: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
5 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,12 @@ | ||
| #include "animal.h" | ||
|
|
||
| using namespace std; | ||
|
|
||
| int main() { | ||
| Shark example1(240, 40.2, 32.7); | ||
| example1.setFinSize(30.6); | ||
| example1.setWeight(200); | ||
| Bass example2(12.3, 15.12, 6.2); | ||
| Horse example3(82.9, 12, 50.5); | ||
| Cat example4(5.2, 8, 4.9); | ||
| cout << example1.getFinSize() << " " << example1.getWeight(); | ||
| return 0; | ||
| } | ||
| }; |
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,96 @@ | ||
| #pragma once | ||
|
|
||
| #include <iostream> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
||
| class Animal { | ||
| private: | ||
| float weight; | ||
| protected: | ||
| Animal() { weight = 0.0; } | ||
| Animal(float weight_) { weight = weight_; }; | ||
| public: | ||
| float weight; // kg | ||
| float getWeight() const { return weight; } | ||
| void setWeight(float value) { weight = value; } | ||
| virtual std::string about() const { return (std::stringstream() << "Weight =" << weight).str(); } | ||
| }; | ||
|
|
||
|
|
||
| class Mammal : public Animal { | ||
| private: | ||
| int pregnancyDuration; | ||
| protected: | ||
| Mammal() { pregnancyDuration = 12; } | ||
| Mammal(float weight_, int pregnancyDuration_) : Animal(weight_) { pregnancyDuration = pregnancyDuration_; }; | ||
| public: | ||
| float pregnancyDuration; // days | ||
| int getPregnancyDuration() const { return pregnancyDuration; } | ||
| void setPregnancyDuration(int value) { pregnancyDuration = value; } | ||
| virtual std::string about() const { return (std::stringstream() << Animal::about() << ", " << "PregnancyDuration =" << pregnancyDuration).str(); } | ||
| }; | ||
|
|
||
|
|
||
| class Cat : public Mammal { | ||
| private: | ||
| float vibrissaLength; | ||
| protected: | ||
| public: | ||
| float vibrissaLength; // meters | ||
| Cat() { vibrissaLength = 0; }; | ||
| Cat(float weight_, int pregnancyDuration_, float vibrissaLength_) : Mammal(weight_, pregnancyDuration_) { vibrissaLength = vibrissaLength_; }; | ||
| float getVibrissaLength() const { return vibrissaLength; } | ||
| void setVibrissaLength(float vibrissaLength_) { vibrissaLength = vibrissaLength_; } | ||
| virtual std::string about() const { return (std::stringstream() << Animal::about() << ", " << Mammal::about() << ", " << "VibrissaLength =" << vibrissaLength).str(); } | ||
| }; | ||
|
|
||
|
|
||
| class Horse : public Mammal { | ||
| private: | ||
| float runningSpeed; | ||
|
|
||
| protected: | ||
| public: | ||
| Horse() { runningSpeed = 0; }; | ||
| Horse(float weight_, int pregnancyDuration_, float runningSpeed_) : Mammal(weight_, pregnancyDuration_) { runningSpeed = runningSpeed_; }; | ||
| float getRunningSpeed() const { return runningSpeed; } | ||
| void setRunningSpeed(float runningSpeed_) { runningSpeed = runningSpeed_; } | ||
| virtual std::string about() const { return (std::stringstream() << Animal::about() << ", " << Mammal::about() << ", " << "RunningSpeed =" << runningSpeed).str(); } | ||
| }; | ||
|
|
||
|
|
||
| class Fish : public Animal { | ||
| private: | ||
| float size; | ||
| protected: | ||
| Fish() { size = 0.0; } | ||
| Fish(float weight_, float size_) : Animal(weight_) { size = size_; }; | ||
| public: | ||
| float getSize() const { return size; } | ||
| void setSize(float size_) { size = size_; } | ||
| virtual std::string about() const { return (std::stringstream() << Animal::about() << ", " << "Size =" << size).str(); } | ||
| }; | ||
|
|
||
|
|
||
| class Bass : public Fish { | ||
| private: | ||
| float gillSize; | ||
| protected: | ||
| public: | ||
| Bass() { gillSize = 0; }; | ||
| Bass(float weight_, float size_, float gillSize_) : Fish(weight_, size_) { gillSize = gillSize_; }; | ||
| float getGillsSize() const { return gillSize; } | ||
| void setGillsSize(float value) { gillSize = value; } | ||
| virtual std::string about() const { return (std::stringstream() << Animal::about() << ", " << Fish::about() << ", " << "GillSize =" << gillSize).str(); } | ||
| }; | ||
|
|
||
|
|
||
| class Shark : public Fish { | ||
| private: | ||
| float finSize; | ||
| protected: | ||
| public: | ||
| Shark() { finSize = 0; }; | ||
| Shark(float weight_, float size_, float finSize_) : Fish(weight_, size_) { finSize = finSize_; }; | ||
| float getFinSize() const { return finSize; } | ||
| void setFinSize(float finSize_) { finSize = finSize_; } | ||
| virtual std::string about() const { return (std::stringstream() << Animal::about() << ", " << Fish::about() << ", " << "FinSize =" << finSize).str(); } | ||
| }; | ||
|
|
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
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
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.
Не хватает демонстрации текущего состояния с выводом на экран.