Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please use C++ to complete Artist.h, Artist.cpp, Artwork.h, and Artwork.cpp files. Main.cpp cannot be changed. 

 

Artist.h Given:

#ifndef ARTISTH
#define ARTISTH

#include <string>
using namespace std;

class Artist{
   public:
      Artist();

      Artist(string artistName, int birthYear, int deathYear);

      string GetName() const;

      int GetBirthYear() const;

      int GetDeathYear() const;

      void PrintInfo() const;
   
   private:
      // TODO: Declare private data members - artistName, birthYear, deathYear

};

#endif

 

Artist.cpp Given:

#include "Artist.h"
#include <iostream>
#include <string>
using namespace std;

// TODO: Define default constructor

// TODO: Define second constructor to initialize
//       private fields (artistName, birthYear, deathYear)

// TODO: Define get functions: GetName(), GetBirthYear(), GetDeathYear()

// TODO: Define PrintInfo() function
//      If deathYear is entered as -1, only print birthYear

 

Artwork.h Given:

#ifndef ARTWORKH
#define ARTWORKH

#include "Artist.h"

class Artwork{
   public:
      Artwork();

      Artwork(string title, int yearCreated, Artist artist);

      string GetTitle();

      int GetYearCreated();

      void PrintInfo();
   
   private:
      // TODO: Declare private data members - title, yearCreated

      // TODO: Declare private data member artist of type Artist

};

#endif

 

Artwork.cpp Given:

#include "Artwork.h"
#include <iostream>

// TODO: Define default constructor

// TODO: Define second constructor to initialize
//       private fields (title, yearCreated, artist)

// TODO: Define get functions: GetTitle(), GetYearCreated()

// TODO: Define PrintInfo() function
//       Call the PrintInfo() function in the Artist class to print an artist's information  

File is marked as read only
1 #include "Artist.h"
2 #include "Artwork.h"
3 #include <iostream>
4 #include <string>
5 using namespace std;
6
7 int main() {
8 string userTitle, userArtistName;
9
10
11 getline(cin, userArtistName);
12
cin >> userBirthYear;
13
14
15 cin.ignore();
16 getline(cin, userTitle);
17
cin >> yearCreated;
18
cin.ignore();
19
20
21
22
23
24
25}
int yearCreated, userBirthYear, userDeathYear;
cin.ignore();
cin >> userDeathYear;
Artist userArtist =
Artwork newArtwork
Current file: main.cpp
=
Artist(userArtistName, userBirthYear, userDeathYear);
Artwork(userTitle, yearCreated, userArtist);
newArtwork. PrintInfo();
Transcribed Image Text:File is marked as read only 1 #include "Artist.h" 2 #include "Artwork.h" 3 #include <iostream> 4 #include <string> 5 using namespace std; 6 7 int main() { 8 string userTitle, userArtistName; 9 10 11 getline(cin, userArtistName); 12 cin >> userBirthYear; 13 14 15 cin.ignore(); 16 getline(cin, userTitle); 17 cin >> yearCreated; 18 cin.ignore(); 19 20 21 22 23 24 25} int yearCreated, userBirthYear, userDeathYear; cin.ignore(); cin >> userDeathYear; Artist userArtist = Artwork newArtwork Current file: main.cpp = Artist(userArtistName, userBirthYear, userDeathYear); Artwork(userTitle, yearCreated, userArtist); newArtwork. PrintInfo();
6.25 LAB: Artwork label (classes/constructors)
Given main(), complete the Artist class (in files Artist.h and Artist.cpp) with constructors to initialize an artist's information, get member
functions, and a PrintInfo() member function. The default constructor should initialize the artist's name to "unknown" and the years of birth
and death to -1. PrintInfo() displays "Artist:", then a space, then the artist's name, then another space, then the birth and death dates in one
of three formats:
(XXXX to YYYY) if both the birth and death years are nonnegative
• (XXXX to present) if the birth year is nonnegative and the death year is negative
(unknown) otherwise
Complete the Artwork class (in files Artwork.h and Artwork.cpp) with constructors to initialize an artwork's information, get member
functions, and a PrintInfo() member function. The default constructor should initialize the title to "unknown", the year created to -1.
PrintInfo() displays an artist's information by calling the PrintInfo() function in the Artist class, followed by the artwork's title and the year
created. Declare a private field of type Artist in the Artwork class.
Ex: If the input is:
Pablo Picasso
1881
1973
Three Musicians
1921
the output is:
Artist: Pablo Picasso (1881 to 1973)
Title: Three Musicians, 1921
Transcribed Image Text:6.25 LAB: Artwork label (classes/constructors) Given main(), complete the Artist class (in files Artist.h and Artist.cpp) with constructors to initialize an artist's information, get member functions, and a PrintInfo() member function. The default constructor should initialize the artist's name to "unknown" and the years of birth and death to -1. PrintInfo() displays "Artist:", then a space, then the artist's name, then another space, then the birth and death dates in one of three formats: (XXXX to YYYY) if both the birth and death years are nonnegative • (XXXX to present) if the birth year is nonnegative and the death year is negative (unknown) otherwise Complete the Artwork class (in files Artwork.h and Artwork.cpp) with constructors to initialize an artwork's information, get member functions, and a PrintInfo() member function. The default constructor should initialize the title to "unknown", the year created to -1. PrintInfo() displays an artist's information by calling the PrintInfo() function in the Artist class, followed by the artwork's title and the year created. Declare a private field of type Artist in the Artwork class. Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881 to 1973) Title: Three Musicians, 1921
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I typed your code in exactly as it was typed in your answer and I am getting a lot of errors. 

In file included from Artist.cpp:1:
Artist.h:17:11: note: candidate is: 'int Artist::GetDeathYear () const'
17 |
int GetDeathYear () const;
^~~~~
Artist.h:7:7: note: 'class Artist' defined here
7 class Artist {
^~~~~~
Artist.cpp:30:6: error: no declaration matches `void Artist::PrintInfo()'
30 void Artist::PrintInfo() {
|
In file included from Artist.cpp:1:
Artist.h:19:12: note: candidate is: 'void Artist::PrintInfo() const'
19 |
void PrintInfo() const;
^~~~~~
^~~~~~~~~
Artist.h:7:7: note: 'class Artist' defined here
7 | class Artist{
^~~~~~
Transcribed Image Text:In file included from Artist.cpp:1: Artist.h:17:11: note: candidate is: 'int Artist::GetDeathYear () const' 17 | int GetDeathYear () const; ^~~~~ Artist.h:7:7: note: 'class Artist' defined here 7 class Artist { ^~~~~~ Artist.cpp:30:6: error: no declaration matches `void Artist::PrintInfo()' 30 void Artist::PrintInfo() { | In file included from Artist.cpp:1: Artist.h:19:12: note: candidate is: 'void Artist::PrintInfo() const' 19 | void PrintInfo() const; ^~~~~~ ^~~~~~~~~ Artist.h:7:7: note: 'class Artist' defined here 7 | class Artist{ ^~~~~~
Program errors displayed here
Artist.cpp:18:8: error: no declaration matches 'std::string Artist::GetName()'
18 string Artist::GetName() {
I
In file included from Artist.cpp:1:
Artist.h:13:14: note: candidate is: 'std::string Artist::GetName() const'
13 I
string GetName() const;
^~~~~~~
^~~~~~
Artist.h:7:7: note: 'class Artist' defined here
7 | class Artist{
^~~~~~
|
Artist.cpp:22:5: error: no declaration matches 'int Artist::GetBirthYear ()'
22 int Artist::GetBirthYear () {
15 |
|
^~~~~~
In file included from Artist.cpp:1:
Artist.h:15:11: note: candidate is: 'int Artist::GetBirthYear () const'
int GetBirthYear () const;
^~~~ ~~~~~~~
Artist.h: 7:7: note: 'class Artist' defined here
7 class Artist {
^~~~~~
Artist.cpp:26:5: error: no declaration matches 'int Artist::GetDeathYear()'
26 int Artist::GetDeathYear () {
^~~~~~
Transcribed Image Text:Program errors displayed here Artist.cpp:18:8: error: no declaration matches 'std::string Artist::GetName()' 18 string Artist::GetName() { I In file included from Artist.cpp:1: Artist.h:13:14: note: candidate is: 'std::string Artist::GetName() const' 13 I string GetName() const; ^~~~~~~ ^~~~~~ Artist.h:7:7: note: 'class Artist' defined here 7 | class Artist{ ^~~~~~ | Artist.cpp:22:5: error: no declaration matches 'int Artist::GetBirthYear ()' 22 int Artist::GetBirthYear () { 15 | | ^~~~~~ In file included from Artist.cpp:1: Artist.h:15:11: note: candidate is: 'int Artist::GetBirthYear () const' int GetBirthYear () const; ^~~~ ~~~~~~~ Artist.h: 7:7: note: 'class Artist' defined here 7 class Artist { ^~~~~~ Artist.cpp:26:5: error: no declaration matches 'int Artist::GetDeathYear()' 26 int Artist::GetDeathYear () { ^~~~~~
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Encryption and decryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education