[cpp] Лаба для дрона
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- #include <iostream>
- #include <string>
- using namespace std;
- class Bow {
- private:
- double strength;
- string BowStringMat;
- public:
- Bow(); //конструктор по умолч
- Bow(double str, string bsm)
- {
- this->strength = str; //конструктор
- this->BowStringMat = bsm;
- }
- Bow(Bow& notebook)
- {
- strength = notebook.strength; //конструктор копирования
- BowStringMat = notebook.BowStringMat;
- }
- string getMaterial() { return this->BowStringMat; }
- int getStrength() { return this->strength; }
- void Restring(double str, string bsm)
- {
- this->BowStringMat = bsm;
- this->strength = str;
- cout << "тетива заменена" << endl;
- }
- void Test()
- {
- cout << "Тестирую прочность лука..." << endl;
- if (strength > 15)
- {
- cout << "Результат: Лук сломается :(" << endl;
- }
- else
- {
- cout << "Результат: Тест пройден успешно!" << endl;
- }
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- cout << "Прочность лука = 15. Не используйте тетиву прочнее лука!" << endl;
- string mat1 = "Тканевая нить";
- Bow BowNumberOne(10, mat1);
- cout << "Текущая тетива: " << BowNumberOne.getMaterial() << endl;
- cout << "Прочность лука: " << BowNumberOne.getStrength() << endl;
- BowNumberOne.Test();
- string mat2 = "Резиновая нить";
- BowNumberOne.Restring(20, mat2);
- cout << "Текущая тетива: " << BowNumberOne.getMaterial() << endl;
- cout << "Прочность лука: " << BowNumberOne.getStrength() << endl;
- BowNumberOne.Test();
- return 0;
- }
Editor
You can edit this paste and save as new:
File Description
- Лаба для дрона
- Paste Code
- 24 Sep-2021
- 1.7 Kb
You can Share it:
Latest Code Pastes