Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Please write a new code as i need mines to be written differently than.docx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Test and refactoring
Test and refactoring
Chargement dans…3
×

Consultez-les par la suite

1 sur 3 Publicité

Please write a new code as i need mines to be written differently than.docx

Télécharger pour lire hors ligne

Please write a new code as i need mines to be written differently than the one ALREADY answered here.
Thanks
client and output provided
Here is the client program that you must use to test your classes.
Here is the correct output. Your output should match this exactly except where random numbers are used.
Solution
class creature {
private :
int type;
int strength;
int hitpoints;
string getspecies() const;
public:
creature();
creature (int newtype, int newstrength, int newhitpoints);
int getDamage() const;
};
string creature :: getspecies() const{
switch(type);
{
case 0:
return \"Human\";
case 1:
retrun \"Cyberdemon\";
case 2:
return \"balrog\";
case 3:
return \"Elf\";
}
return unkown;
}
int creature :: getDamage(){
int damage;
damage=(rand()%strength)+1;
cout<<getspecies()<<\"attacks for\"<<damage<<\"point\"<<endl;
if(type==2 || type==1){
if (rand()%4==0)
{
damage=damage+50;
cout<<\"Denomic attacks inflicts 50 Additional damage point:\"<<endl;
}
}
if(type ==3)
{
if rand()%2==0)
{
cout<<\"Magical attacks inflict\"<<damage<<\"Additional damage points:\"<<endl;
damage*=2;
}
}
if (type==2)
{ int damage2=rand()%strength)+1;
cout<<\"balrog speed attack inflicts\"<<damage2<<\"Additional damage points:\"<<endl;
damage=damage+damage2;
}
return damage;
}
.

Please write a new code as i need mines to be written differently than the one ALREADY answered here.
Thanks
client and output provided
Here is the client program that you must use to test your classes.
Here is the correct output. Your output should match this exactly except where random numbers are used.
Solution
class creature {
private :
int type;
int strength;
int hitpoints;
string getspecies() const;
public:
creature();
creature (int newtype, int newstrength, int newhitpoints);
int getDamage() const;
};
string creature :: getspecies() const{
switch(type);
{
case 0:
return \"Human\";
case 1:
retrun \"Cyberdemon\";
case 2:
return \"balrog\";
case 3:
return \"Elf\";
}
return unkown;
}
int creature :: getDamage(){
int damage;
damage=(rand()%strength)+1;
cout<<getspecies()<<\"attacks for\"<<damage<<\"point\"<<endl;
if(type==2 || type==1){
if (rand()%4==0)
{
damage=damage+50;
cout<<\"Denomic attacks inflicts 50 Additional damage point:\"<<endl;
}
}
if(type ==3)
{
if rand()%2==0)
{
cout<<\"Magical attacks inflict\"<<damage<<\"Additional damage points:\"<<endl;
damage*=2;
}
}
if (type==2)
{ int damage2=rand()%strength)+1;
cout<<\"balrog speed attack inflicts\"<<damage2<<\"Additional damage points:\"<<endl;
damage=damage+damage2;
}
return damage;
}
.

Publicité
Publicité

Plus De Contenu Connexe

Similaire à Please write a new code as i need mines to be written differently than.docx (20)

Plus par helenc18 (20)

Publicité

Plus récents (20)

Please write a new code as i need mines to be written differently than.docx

  1. 1. Please write a new code as i need mines to be written differently than the one ALREADY answered here. Thanks client and output provided Here is the client program that you must use to test your classes. Here is the correct output. Your output should match this exactly except where random numbers are used. Solution class creature { private : int type; int strength; int hitpoints; string getspecies() const; public: creature(); creature (int newtype, int newstrength, int newhitpoints); int getDamage() const; };
  2. 2. string creature :: getspecies() const{ switch(type); { case 0: return "Human"; case 1: retrun "Cyberdemon"; case 2: return "balrog"; case 3: return "Elf"; } return unkown; } int creature :: getDamage(){ int damage; damage=(rand()%strength)+1; cout<<getspecies()<<"attacks for"<<damage<<"point"<<endl; if(type==2 || type==1){ if (rand()%4==0) { damage=damage+50; cout<<"Denomic attacks inflicts 50 Additional damage point:"<<endl;
  3. 3. } } if(type ==3) { if rand()%2==0) { cout<<"Magical attacks inflict"<<damage<<"Additional damage points:"<<endl; damage*=2; } } if (type==2) { int damage2=rand()%strength)+1; cout<<"balrog speed attack inflicts"<<damage2<<"Additional damage points:"<<endl; damage=damage+damage2; } return damage; }

×