Answer to Question #309621 in C++ for Boi

Question #309621

Design a class art that contain the details of artist, country and class info contain the details of year and art-tyoe(fancy, historic or modern) . Use a function for displaying the details by reading data from class art and info. The function used for displaying is not a member of any class.

1
Expert's answer
2022-03-11T07:24:19-0500


#include <iostream>
#include <string>


using namespace std;
class Art
{
private:
	string artistName;
	int year;
	string arttype;
	string country;
public:




	void read(){
		cout<<"Enter artist name: ";
		getline(cin,artistName);
		cout<<"Enter year: ";
		cin>>year;
		cout<<"Select art type: (1. Fancy, 2. Historic, 3. Modern): ";
		int type;
		cin>>type;
		if(type==1){
			arttype="Fancy";
		}
		else if(type==2){
			arttype="Historic";
		}else if(type==3){
			arttype="Modern";
		}
		cin.ignore();
		cout<<"Enter country: ";
		getline(cin,country);
	}


	string getArtistName(){
		return artistName;
	}
	
	int getYear(){
		return year;
	}
	
	string getArttype(){
		return arttype;
	}
	string getCountry(){
		return country;
	}
};
void displayArt(Art art)
{
	cout << "Artist name: " << art.getArtistName() << endl;
	cout << "Year: " << art.getYear() << endl;
	cout << "Art-type: " << art.getArttype()<< endl;
	cout << "Country: " << art.getCountry()<< endl;
}




int main() {
	Art art;
	art.read();


	displayArt(art);
	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment