[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
классы
vilgosДата: Вт, 16 Июн 2015, 20:48 | Сообщение # 1
Старший программист
Группа: Модераторы
Сообщений: 76
Репутация: 0
Статус: Offline

Код
// class1.cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"  
#include <iostream>   
#include <time.h>   
#include <Windows.h>   
#include <string>  

using namespace std;
//-------------1  

//class Cat  
//{  
//public:  
//   Cat();  
//   ~Cat();  
//   void sleepCat();  
//   void zhret();  
//   void gulyaet();  
//   void seyCat();  
//   void getValue();  
//private:  
//   string name;  
//   float ves;  
//   int age;  
//   string color;  
//   string sey;  
//};  
//  
//Cat::Cat()  
//{  
//   cout << "Vvedite dannie kota!" << endl;  
//   cout << "Imya - ";  
//   cin >> this->name;  
//   cout << "Vozrast - ";  
//   cin >> this->age;  
//   cout << "Ves - ";  
//   cin >> this->ves;  
//   cout << "Golos - ";  
//   cin >> this->sey;  
//   cout << "Color - ";  
//   cin >> this->color;  
//  
//}  
//void Cat::sleepCat(){  
//   cout << "spit" << endl;  
//}  
//void Cat::zhret(){  
//   cout << "zhret" << endl;  
//   this->ves += 0.01;  
//}  
//void Cat::gulyaet(){  
//   cout << "gulyaet" << endl;  
//   this->ves -= 0.005;  
//}  
//void Cat::seyCat(){  
//   cout << this->sey << endl << endl;  
//}  
//void Cat::getValue(){  
//   cout << endl << ".........................." << endl;  
//   cout << "Dannie kota!" << endl;  
//   cout << "Imya - " << this->name << endl;  
//   cout << "Vozrast - " << this->age << endl;  
//   cout << "Ves - " << this->ves << endl;  
//   cout << "Color - " << this->color << endl << endl;  
//}  
//Cat::~Cat()  
//{  
//   system("cls");  
//   cout << "Kot ybezhal!!!"<<endl;  
//   _gettch();  
//}  
//int main()  
//{  
//   Cat A;  
//   while (true)  
//   {  
//      system("cls");  
//      A.getValue();  
//      A.seyCat();  
//      int a = 0;  
//      cout << "deistvie (1-spit,2-zhret,3-gulyaet,0-ybezhal)";  
//      cin >> a;  
//      cout << endl;  
//      switch (a)  
//      {  
//      case 1:  
//         A.sleepCat();  
//         break;  
//      case 2:  
//         A.zhret();  
//         break;  
//      case 3:  
//         A.gulyaet();  
//         break;  
//      default:  
//         break;  
//      }  
//      if (a == 0) break;  
//   }  
//  
//     
//   return 0;  
//}  

//-------------2
class Kvadrat
{
public:
    Kvadrat();
    ~Kvadrat();
    void getValue();
    void name();
protected:
    int P;
    int S;
    int a;
};

Kvadrat::Kvadrat()
{
    cout << "Vvedite storonu - ";
    cin >> this->a;
}

Kvadrat::~Kvadrat()
{
}
void Kvadrat::name() {
    cout << "Kvadrat" << endl;
}
void Kvadrat::getValue() {
    cout << "perimetr = " << this->a * 4 << endl;
    cout << "ploshchad = " << this->a*this->a << endl << endl;
}

class Pryamoygolnik : public Kvadrat
{
public:
    Pryamoygolnik();
    ~Pryamoygolnik();
    void getValue();
    void name();
protected:
    int b;
};

Pryamoygolnik::Pryamoygolnik()
{
    cout << "Vvedite storonu - ";
    cin >> this->b;
}

Pryamoygolnik::~Pryamoygolnik()
{
}
void Pryamoygolnik::name() {
    cout << "Pryamoygolnik" << endl;
}
void Pryamoygolnik::getValue() {
    cout << "perimetr = " << (this->a + this->b) * 2 << endl;
    cout << "ploshchad = " << this->a*this->b << endl << endl;
}

class Trapetsiya : public Pryamoygolnik
{
public:
    Trapetsiya();
    ~Trapetsiya();
    void getValue();
    void name();
private:
    int c;
    int d;
};

Trapetsiya::Trapetsiya()
{
    cout << "Vvedite storonu - ";
    cin >> this->c;
    cout << "Vvedite storonu - ";
    cin >> this->d;
}

Trapetsiya::~Trapetsiya()
{
}
void Trapetsiya::name() {
    cout << "Trapetsiya" << endl;
}
void Trapetsiya::getValue() {
    cout << "perimetr = " << this->a + this->b+ this->c+ this->d << endl;
    float tmp = (pow(this->b - this->a, 2) + pow(this->c, 2) - pow(this->d, 2)) / (2 * (this->b - this->a));
    cout << "ploshchad = " <<(float) (this->a+this->b)/2*sqrt(pow(this->c,2)-pow(tmp,2)) << endl << endl;
}

class Paralelogram : public Pryamoygolnik
{
public:
    Paralelogram();
    ~Paralelogram();
    void getValue();
    void name();
protected:
    int corner;
};

Paralelogram::Paralelogram()
{
    cout << "Vvedite ygol - ";
    cin >> this->corner;
}
void Paralelogram::getValue() {
    cout << "perimetr = " << (this->a + this->b) * 2 << endl;
    cout << "ploshchad = " << this->a*this->b*sin(this->corner) << endl << endl;
}
Paralelogram::~Paralelogram()
{
}
void Paralelogram::name() {
    cout << "Paralelogram" << endl;
}

class Romb : public Paralelogram
{
public:
    Romb();
    ~Romb();
    void getValue();
    void name();
private:

};

Romb::Romb()
{
}

Romb::~Romb()
{
}
void Romb::getValue() {
    cout << "perimetr = " << (this->a + this->b) * 2 << endl;
    cout << "ploshchad = " << this->a*this->b*sin(this->corner) << endl;
}
void Romb::name() {
    cout << "Romb" << endl;
}

int main() {
    Kvadrat A;
    A.name();
    A.getValue();
    Pryamoygolnik B;
    B.name();
    B.getValue();
    Paralelogram C;
    C.name();
    C.getValue();
    Romb D;
    D.name();
    D.getValue();
    Trapetsiya E;
    E.name();
    E.getValue();

    _gettch();
    return 0;
}
 
vilgosДата: Ср, 17 Июн 2015, 21:04 | Сообщение # 2
Старший программист
Группа: Модераторы
Сообщений: 76
Репутация: 0
Статус: Offline
Код
// ConsoleApplication2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>    
#include <time.h>    
#include <Windows.h>    
#include <string>   

using namespace std;

class Tehnika
{
public:
    Tehnika();
    ~Tehnika();
    void getValue();
protected:
    string name;
    string model;
    int year;
    float massa;
    int height;
    int width;
    string color;
    int power;
    int thickness;

};

Tehnika::Tehnika()
{
    cout << "Vvedite nazvanie pribora - ";
    cin >> this->name;
    cout << "Vvedite model pribora - ";
    cin >> this->model;
    cout << "Vvedite god vipyska pribora - ";
    cin >> this->year;
    cout << "Vvedite massy pribora - ";
    cin >> this->massa;
    cout << "Vvedite visoty pribora - ";
    cin >> this->height;
    cout << "Vvedite shirihy pribora - ";
    cin >> this->width;
    cout << "Vvedite tolshchiny pribora - ";
    cin >> this->thickness;
    cout << "Vvedite tsvet pribora - ";
    cin >> this->color;
    cout << "Vvedite moshchnost' pribora - ";
    cin >> this->power;
}

Tehnika::~Tehnika()
{
}
void Tehnika::getValue(){
    cout << endl << "---------------------------------------------------" << endl;
    cout << "Nazvanie pribora - " << this->name << endl;
    cout << "Model pribora - " << this->model << endl;
    cout << "God vipyska pribora - " << this->year << endl;
    cout << "Massa pribora - " << this->massa << endl;
    cout << "Visota pribora - " << this->height << endl;
    cout << "Shiriha pribora - " << this->width << endl;
    cout << "Tolshchiny pribora - " << this->thickness << endl;
    cout << "Tsvet pribora - " << this->color << endl;
    cout << "Moshchnost' pribora - " << this->power << endl;
}
class MelkoButova : public Tehnika
{
public:
    MelkoButova();
    ~MelkoButova();
    void getValue();
protected:
    bool kyhonnaya;
    bool YhodZaSoboi;
    bool YhodZaDomom;
    string purpose;
};

MelkoButova::MelkoButova()
{
    while (true)
    {
       cout << "Pribor kuhonniy?(1-da,0-net) - ";
       cin >> this->kyhonnaya;
       if (this->kyhonnaya == 1){
          this->YhodZaDomom = 0;  
          this->YhodZaSoboi = 0;
          break;
       }
       else{
          cout << "Pribor dlya yhoda za soboy?(1-da,0-net) - ";
          cin >> this->YhodZaSoboi;
          if (this->YhodZaSoboi==1){
             this->YhodZaDomom = 0;
             this->kyhonnaya = 0;
             break;
          }
          else{
             cout << "Pribor dlya yhoda za domom?(1-da,0-net) - ";
             cin >> this->YhodZaDomom;
             if (this->YhodZaDomom == 1){
                this->YhodZaSoboi = 0;
                this->kyhonnaya = 0;
                break;
             }
          }
       }
    }
    if (this->kyhonnaya != 1)
       this->~MelkoButova();
    cout << "Vvedite naznachenie pribora - ";
    cin >> this->purpose;
}

MelkoButova::~MelkoButova()
{
    cout << "ne to" << endl;
    _gettch();
    exit(0);
}
void MelkoButova::getValue(){
    if (this->kyhonnaya==1)         cout << "Pribor kuhonniy" << endl;
    if (this->YhodZaSoboi == 1)      cout << "Pribor dlya yhoda za soboy" << endl;
    if (this->YhodZaDomom == 1)      cout << "Pribor dlya yhoda za domom"<<endl;
    cout << "Naznachenie pribora - " << this->purpose << endl;
}
class CoffeMashina : public MelkoButova
{
public:
    CoffeMashina();
    ~CoffeMashina();
    void getValue();
private:
    string type;
    bool autoCooking;
    bool milkContainer;
    string typeCoffe;
    float sizeWaterContainer;
    int pressure;

};

CoffeMashina::CoffeMashina()
{
    cout << "Vvedite tip cofemashini - ";
    cin >> this->type;
    cout << "Y cohemashini est' vozmozhnist' avtogotovki?(1-da, 0-net) - ";
    cin >> this ->autoCooking;
    cout << "Y cohemashini est' konteyner dlya moloka?(1-da, 0-net) - ";
    cin >> this->milkContainer;
    cout << "Kakoi tip kofe ispol'zyetsya? - ";
    cin >> this->typeCoffe;
    cout << "Vvedite rozmer vodyanogo konteynera cofemashini - ";
    cin >> this->sizeWaterContainer;
    cout << "Vvedite davlenie cofemashini na vihode- ";
    cin >> this->pressure;
}

CoffeMashina::~CoffeMashina()
{
}
void CoffeMashina::getValue(){
    this->Tehnika::getValue();
    this->MelkoButova::getValue();
    cout << "Tip cofemashini - " << this->type << endl;
    cout << "Y cohemashini est' vozmozhnist' avtogotovki?(1-da, 0-net) - " << this->autoCooking << endl;
    cout << "Y cohemashini est' konteyner dlya moloka?(1-da, 0-net) - " << this->milkContainer << endl;
    cout << "Tip kofe ispol'zyetsya - " << this->typeCoffe << endl;
    cout << "Rozmer vodyanogo konteynera cofemashini - " << this->sizeWaterContainer << endl;
    cout << "Davlenie cofemashini na vihode- " << this->pressure << endl;
}

class Hlebopechka : public MelkoButova
{
public:
    Hlebopechka();
    ~Hlebopechka();
    void getValue();
private:
    float massaHleba;
    bool sizeHleb;
    bool displey;
    string control;
    int programm;
};

Hlebopechka::Hlebopechka()
{
    cout << "Vvedite maksimal'no vozmozhnyiy massy hleba - ";
    cin >> this->massaHleba;
    cout << "Est' vozmozhnost' smeni rozmera hleba?(1-da, 0-net)  - ";
    cin >> this->sizeHleb;
    cout << "Est' displey?(1-da, 0-net)  - ";
    cin >> this->displey;
    cout << "Tip ypravleniya  - ";
    cin >> this->control;
    cout << "kolichestvo programm  - ";
    cin >> this->programm;
     
}

Hlebopechka::~Hlebopechka()
{
}
void Hlebopechka::getValue(){
    this->Tehnika::getValue();
    this->MelkoButova::getValue();
    cout << "Maksimal'no vozmozhnyia massa hleba - "<< this->massaHleba<<endl;
    cout << "Est' vozmozhnost' smeni rozmera hleba?(1-da, 0-net)  - " << this->sizeHleb << endl;
    cout << "Est' displey?(1-da, 0-net)  - " << this->displey << endl;
    cout << "Tip ypravleniya  - " << this->control << endl;
    cout << "Kolichestvo programm  - " << this->programm << endl;
}
int main()
{
    CoffeMashina A;
    Hlebopechka B;
    system("cls");
    A.getValue();
    B.getValue();
    _gettch();
    return 0;
}



 
miffaДата: Ср, 17 Июн 2015, 21:05 | Сообщение # 3
Немного понимает логику
Группа: Модераторы
Сообщений: 18
Репутация: 0
Статус: Offline
Код
// naslidyBan9.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <Windows.h>
#include <stdlib.h>
#include <string>

using namespace std;

class IIpibop
{
public:
    IIpibop();
    ~IIpibop();

protected:
    string name;
    string model;
    int year;
    int mas;
    string color;
    int w;
    int h;
    int power;
};

IIpibop::IIpibop()
{
    cout << "BBediTe Ha3By IIpibopa :" << endl;
    cout << "BBediTe Im9 :" << endl;
    cin >> this->name;
    cout << "BBediTe model" << endl;
    cin >> this->model;
    cout << "BBediTe color" << endl;
    cin >> this->color;
    cout << "BBediTe Bec" << endl;
    cin >> this->mas;
    cout << "BBediTe power" << endl;
    cin >> this->power;
    cout << "BBediTe Bucoty :" << endl;
    cin >> this->h;
    cout << "BBediTe IIIupeny :" << endl;
    cin >> this->w;
    cout << "BBediTe god :" << endl;
    cin >> this->year;
}

IIpibop::~IIpibop()
{

}
class MelbuTTex : public IIpibop
{
public:
    MelbuTTex();
    ~MelbuTTex();

protected:
    bool KyxoHa;
    bool Yxod;
};

MelbuTTex::MelbuTTex()
{
    cout << "DJi9 kyxHi ? 1-da 0-net" << endl;
    cin >> this->KyxoHa;
    cout << "DJi9 yxoda ?" << endl;
    cin >> this->Yxod;
}

MelbuTTex::~MelbuTTex()
{
    _gettch();
    exit(0);
}

class cofeBapka:public MelbuTTex
{
public:
    cofeBapka();
    ~cofeBapka();
    void get();

private:

    string tip;
     
};

cofeBapka::cofeBapka()
{
    cout << "BBediTe tip" << endl;
    cin >> this->tip;
}

cofeBapka::~cofeBapka()
{

}

void cofeBapka::get(){
    system("cls");
    cout <<"name-"<< this->name<<endl;
    cout << "model-" << this->model << endl;
    cout << "god-" << this->year << endl;
    cout << "Bucota-" << this->h << endl;
    cout << "IIIupuHa-" << this->w << endl;
    cout << "Power-" << this->power << endl;
    cout << "Bec-" << this->mas << endl;
    cout << "color-" << this->color << endl;
    if (this->KyxoHa == 1){
       cout << "DJI9 kyxHi-Da" << endl;
    }
    if (this->KyxoHa == 0){
       cout << "DJI9 kyxHi?-HeT" << endl;
    }
    cout << "Tip-" << this->tip << endl;
    cout << "IIpibor gotoBit takoi cofe: " << endl;
    cout << "Ecspreso" << endl << "Late" << endl << "Americano" << endl << "KapychiHo" << endl;
     
}
class XleboIIe4ka:public MelbuTTex
{
public:
    XleboIIe4ka();
    ~XleboIIe4ka();
    void gett();
private:
    bool formaK;
    bool formaP;
};
XleboIIe4ka::XleboIIe4ka()
{
    cout << "Forma krygla9?" << endl;
    cin >> formaK;
    cout << "Forma pr9moygolbna9?" << endl;
    cin >> formaP;
}

XleboIIe4ka::~XleboIIe4ka()
{
}
void XleboIIe4ka::gett(){
    system("cls");
    cout << "name-" << this->name << endl;
    cout << "model-" << this->model << endl;
    cout << "god-" << this->year << endl;
    cout << "Bucota-" << this->h << endl;
    cout << "IIIupuHa-" << this->w << endl;
    cout << "Power-" << this->power << endl;
    cout << "Bec-" << this->mas << endl;
    cout << "color-" << this->color << endl;
    if (this->KyxoHa == 1){
       cout << "DJI9 kyxHi-Da" << endl;
    }
    if (this->KyxoHa == 0){
       cout << "DJI9 kyxHi?-HeT" << endl;
    }
    if (this->formaK == 1){
       cout << "Fopma krygJIa9-ECTb" << endl;
    }
    if (this->formaK == 0){
       cout << "Fopma krygJIa9-HeT" << endl;
    }
    if (this->formaP == 1){
       cout << "Fopma IIp9moygoJIHa9-ECTb" << endl;
    }
    if (this->formaP == 0){
       cout << "Fopma IIp9moygoJIHa9-HeT" << endl;
    }
    cout << "IIpibor gotoBit takoi xJIeb: " << endl;
    cout << "baToH" << endl << "baget" << endl << "byJIka" << endl << "bybJIuk" << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
    int i;

    for (;;){
       cout << "1-BBecTi cofeBapky, 2-BBecti XJIeboIIe4ky" << endl;
       cin >> i;
       if (i == 1){
          cofeBapka A;
          A.get();
       }
       if (i == 2){
          XleboIIe4ka B;
          B.gett();
       }
       else
          cout << "error";
    }
    _gettch();
    return 0;
}



 
miffaДата: Чт, 18 Июн 2015, 20:27 | Сообщение # 4
Немного понимает логику
Группа: Модераторы
Сообщений: 18
Репутация: 0
Статус: Offline

Код
// program.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>     
#include <time.h>     
#include <Windows.h>     
#include <string>    

using namespace std;

class Human
{
public:
    Human();
    ~Human();
    void virtual kick() = 0;

protected:
    string name;
    double health;
};

Human::Human()
{
    cout << "BBediTe im9" << endl;
    cin >> this->name;
    cout << "BBediTe HP" << endl;
    cin >> this->health;
}

Human::~Human()
{
}
class Horserider :public virtual Human
{
public:
    Horserider();
    ~Horserider();
    void kick();
    void move();
    void get();
    void metod();
protected:
    double damage;

};

Horserider::Horserider()
{
     
}

Horserider::~Horserider()
{
}
void Horserider::metod(){
cout << "BBediTe damage" << endl;
    cin >> this->damage;
}
void Horserider::kick(){
    cout << this->name << " HaHec " << this->damage << " ypoHa i 3aBaJIiJI Bcex XpeCTi9H" << endl;
}
void Horserider::move(){

}
void Horserider::get(){
    cout << "name HorseRider - " << this->name << endl;
    cout << "HP - " << this->health << endl;
    cout << "Damage - " << this->damage << endl;
}
class Knight:public virtual Human
{
public:
    Knight();
    ~Knight();
    void kick();
    void move();
    void get();
    void metod();  
protected:
    double damage;
};

Knight::Knight()
{
}

Knight::~Knight()
{
}
void Knight::metod(){
    cout << "BBediTe damage" << endl;
    cin >> this->damage;
}
void Knight::kick(){
    cout <<this->name<< " HaHec " << this->damage << " ypoHa i 3aBaJIiJI Bcex XpeCTi9H" << endl;
}
void Knight::move(){

}
void Knight::get(){
cout << "name Knight - " << this->name<<endl;
    cout << "HP - " << this->health<<endl;
    cout << "Damage - " << this->damage << endl;
}
class KnightonHorse:public Knight, public Horserider
{
public:
    KnightonHorse();
    ~KnightonHorse();
    void kick();
    void move();
    void get();
    void metod();
private:
    double damage;
};

KnightonHorse::KnightonHorse()
{
     
}

KnightonHorse::~KnightonHorse()
{
}
void KnightonHorse::metod(){
    cout << "BBediTe damage" << endl;
    cin >> this->damage;
}

void KnightonHorse::get(){
cout << "name KnighOnHorse - " << this->name<<endl;
cout << "HP - " << this->health<<endl;
cout << "Damage - " << this->damage<<endl;
}

void KnightonHorse::kick(){
    cout << this->name << " HaHec " << this->damage << " ypoHa i 3aBaJIiJI Bcex XpeCTi9H" << endl;
}

int _tmain(int argc, _TCHAR* argv[])
{
    Horserider A;
    A.metod();
    Knight B;
    B.metod();
    KnightonHorse C;
    C.metod();
    system("cls");
    A.get();
    B.get();
    C.get();
    Sleep(1000);
    int key;
    for (;;){
       cin >> key;
       switch (key)
       {
       case 1:
       {
          A.kick();
          break;
       }
       case 2:
       {
          B.kick();
          break;
       }
       case 3:
          C.kick();
          break;
       default:

          break;
       }
    }
    _gettch();
    return 0;
}
 
vilgosДата: Чт, 18 Июн 2015, 20:29 | Сообщение # 5
Старший программист
Группа: Модераторы
Сообщений: 76
Репутация: 0
Статус: Offline
Код
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"  
#include <iostream>      
#include <time.h>      
#include <Windows.h>      
#include <string>     

using namespace std;

class Humann
{
public:
    Humann();
    ~Humann();
    int virtual kick() = 0;
    void initValue();
protected:
    string name;
    float health;
    int damage;
    int armor;
};
Humann::Humann()
{

}
Humann::~Humann()
{
}
void Humann::initValue(){
    cout << "Imya - ";
    cin >> this->name;
    cout << "HP - ";
    cin >> this->health;
}
class Warrior :public virtual Humann
{
public:
    Warrior();
    ~Warrior();
    int kick();
    void initValue();
    void getValue();
    int war(int a, int b);
    int protection();
protected:

};
Warrior::Warrior()
{

}
Warrior::~Warrior()
{
}
void Warrior::initValue(){
    cout << endl << "Warrior" << endl;
    Humann::initValue();
    cout << "Yron - ";
    cin >> this->damage;
    cout << "Bron9 - ";
    cin >> this->armor;
}
int Warrior::kick(){
    cout << "Warrior nanes ydar!" << endl;
    return this->damage;
}
int Warrior::war(int a,int b){
    this->health =this->health-(b-(b*a)/100);
    if (this->health <= 0)
       return 0;
    return 1;
}
void Warrior::getValue(){
    cout << "********************" << endl;
    cout << "Warrior." << endl;
    cout << "Im9 - " << this->name << endl;
    if (this->health <= 0)   cout << "Ymer" << endl;
    else   cout << "HP - " << this->health << endl;
    cout << "Yron - " << this->damage << endl;
    cout << "Bron9 - " << this->armor << endl;
}
int Warrior::protection(){
    cout << "Zablokirovano " << this->armor << " % yrona" << endl;
    return this->armor;
}

class HorseRider :public virtual Humann
{
public:
    HorseRider();
    ~HorseRider();
    int kick();
    void initValue();
    void getValue();
    int war(int a, int b);
    int protection();
protected:

};
HorseRider::HorseRider()
{

}
HorseRider::~HorseRider()
{
}
void HorseRider::initValue(){
    cout << endl << "HorseRider" << endl;
    Humann::initValue();
    cout << "Yron - ";
    cin >> this->damage;
    cout << "Bron9 - ";
    cin >> this->armor;
}
int HorseRider::kick(){
    cout << "HorseRider nanes ydar!" << endl;
    return this->damage;
}
void HorseRider::getValue(){
    cout << "********************" << endl;
    cout << "HorseRider." << endl;
    cout << "Im9 - " << this->name << endl;
    if (this->health <= 0)   cout << "Ymer" << endl;
    else   cout << "HP - " << this->health << endl;
    cout << "Yron - " << this->damage << endl;
    cout << "Bron9 - " << this->armor << endl;
}
int HorseRider::war(int a, int b){
    this->health = this->health - (b - (b*a) / 100);
    if (this->health <= 0)
       return 0;
    return 1;
}
int HorseRider::protection(){
    cout << "Zablokirovano " << this->armor << " % yrona" << endl;
    return this->armor;
}

class Knight : public virtual Warrior, public virtual HorseRider
{
public:
    Knight();
    ~Knight();
    int kick();
    void initValue();
    void getValue();
    int war(int a, int b);
    int protection();
protected:

};
Knight::Knight()
{

}
Knight::~Knight()
{
}
int Knight::kick(){
    cout << "Knight nanes ydar!" << endl;
    return this->damage;
}
void Knight::initValue(){
    cout << endl << "Knight" << endl;
    Humann::initValue();
    cout << "Yron - ";
    cin >> this->damage;
    cout << "Bron9 - ";
    cin >> this->armor;
}
void Knight::getValue(){
    cout << "********************" << endl;
    cout << "Knight." << endl;
    cout << "Im9 - " << this->name << endl;
    if (this->health <= 0)   cout << "Ymer" << endl;
    else   cout << "HP - " << this->health << endl;
    cout << "Yron - " << this->damage << endl;
    cout << "Bron9 - " << this->armor << endl;
}
int Knight::war(int a, int b){
    this->health = this->health - (b - (b*a) / 100);
    if (this->health <= 0)
       return 0;
    return 1;
}
int Knight::protection(){
    cout << "Zablokirovano " << this->armor << " % yrona" << endl;
    return this->armor;
}

class BattleArena : public Knight
{
public:
    BattleArena();
    ~BattleArena();
    void battle();
    int kick();
private:
    int type;
};
BattleArena::BattleArena()
{
    cout << "viberite tip bo9." << endl
       << "1-Warrior vs Horse Rider;" << endl
       << "2-Warrior vs Knight;" << endl
       << "3-Knight vs Horse rider." << endl;
    cin >> this->type;
}
BattleArena::~BattleArena()
{
}
void BattleArena::battle(){
    Warrior A;
    HorseRider B;
    Knight C;
    int i = 1;
    if (this->type == 1){
       A.initValue();
       B.initValue();
       while (true)
       {
          system("cls");
          cout << "\t\t\tRound " << i << endl;
          int check = A.war(A.protection(),B.kick());
          int check2 = B.war(B.protection(),A.kick());
          A.getValue();
          B.getValue();
          i++;
          if (check == 0 || check2 == 0){
             if (check == 0) cout << endl << "Pobedil Warrior" << endl;
             else  cout << endl << "Pobedil HorseRider" << endl;
             break;
          }
          Sleep(2000);
       }
        
    }
    else if (this->type == 2){
       A.initValue();
       C.initValue();
       while (true)
       {
          system("cls");
          cout << "\t\t\tRound " << i << endl;
          int check = A.war(C.protection(),C.kick());
          int check2 = C.war(A.protection(),A.kick());
          A.getValue();
          C.getValue();
          i++;
          if (check == 0 || check2 == 0){
             if (check == 0) cout << endl << "Pobedil Warrior" << endl;
             else  cout << endl << "Pobedil Knight" << endl;
             break;
          }
          Sleep(2000);
       }

    }
    else if (this->type == 3){
       B.initValue();
       C.initValue();
       while (true)
       {
          system("cls");
          cout << "\t\t\tRound " << i << endl;
          int check = B.war(B.protection(),C.kick());
          int check2 = C.war(C.protection(),B.kick());
          B.getValue();
          C.getValue();
          i++;
          if (check == 0 || check2 == 0){
             if (check == 0) cout << endl << "Pobedil HorseRider" << endl;
             else  cout << endl << "Pobedil Knight" << endl;
             break;
          }
          Sleep(2000);
       }
    }

}
int BattleArena::kick(){
    return 0;

}
int main()
{
    BattleArena A;
    A.battle();
    _gettch();
    return 0;
}



 
  • Страница 1 из 1
  • 1
Поиск: