Jul 1, 2021 at 9:22pm UTC
//Band.CPP
#include "Band.hpp"
Band::Band(int members, int foundingYear):members(members),
founding_year(foundingYear){}
Band::Band(int members){
this->members = members;
this->founding_year = 2021;
}
int Band::get_members(){
return this->members;
}
string Band::get_age(){
if ((2021 - this->founding_year) < 5 ){
return "young";
} else{
return "old";
}
}
//Band.hpp
#include<iostream>
using namespace std;
class Band{
public:
Band(int members, int foundingYear);
explicit Band(int members);
virtual string get_age();
int get_members();
private:
int members;
int founding_year;
};
//Metal.hpp
#include "Band.hpp"
class Metal:public Band{
public:
Metal(int darkness, int members, int foundingYear);
string get_age();
private:
int darkness;
};
//Metal.cpp
#include "Metal.hpp"
Metal::Metal(int darkness, int members, int foundingYear) :
Band(members, foundingYear){
if (darkness <= 1000 && darkness >= 0 ){
this->darkness=darkness;
}else{
cout << "error : Metal the darkness must be in appropriate range" <<endl;
}
}
string Metal::get_age(){
string darkness_string;
if(this->darkness > 800){
darkness_string = "profoundly dark!!!";
}else if(this->darkness >= 200){
darkness_string = "extremely dark!!";
}else if(this->darkness >= 100){
darkness_string = "very dark!";
}else if(this->darkness >= 10){
darkness_string = "dark.";
}else{
darkness_string ="not very dark at all.";
}
string tmp = "this" +Band::get_age() + "metal band is " +darkness_string;
return tmp;
}
????//
//
Band *bublegum = new Band(4,2019);
Metal *danzigwithtearsinmyeyes = new Metal(800,4,2019);
//
cout << bublegum->get_age() << endl;
cout << danzigwithtearsinmyeyes->get_age() << endl;
Jul 2, 2021 at 11:03am UTC
I believe you've already been asked to use code tags around your code. What you've posted is unreadable as it stands.