SlideShare a Scribd company logo
1 of 4
C++
10.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:
1881 and 1973 being the birth and death years respectively, with 1921 being the year the work
was created, the output is:
Ex: If the input is:
the output is:
Ex: If the input is:
the output is:
Code provided, fill in where needed on each (there is comments) .cpp or .h:
main.cpp:
#include "Artist.h"
#include "Artwork.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
string userTitle, userArtistName;
int yearCreated, userBirthYear, userDeathYear;
getline(cin, userArtistName);
getline(cin, userTitle);
cin >> userBirthYear;
cin >> userDeathYear;
cin >> yearCreated;
Artist userArtist = Artist(userArtistName, userBirthYear, userDeathYear);
Artwork newArtwork = Artwork(userTitle, yearCreated, userArtist);
newArtwork.PrintInfo();
}
Artist.h:
#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:
#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:
#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:
#include "Artwork.h"
#include <iostream>
// TODO: Define default constructor
Artwork::Artwork()
{
title = "";
yearCreated = 0;
}
// TODO: Define second constructor to initialize
// private fields (title, yearCreated, artist)
Artwork::Artwork(string title, int yearCreated, Artist artist)
{
this->title = title;
this->yearCreated = yearCreated;
this->artist = artist;
}

More Related Content

Similar to C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx

C++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdfC++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdfherminaherman
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfstopgolook
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfinfo114
 
PFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdfPFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdfmailadmin1
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxSirRafiLectures
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdfaathiauto
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Deepak Singh
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingMeghaj Mallick
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdfaathmaproducts
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat SheetHortonworks
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202Mahmoud Samir Fayed
 
Function for python for the embedded system
Function for python for the embedded systemFunction for python for the embedded system
Function for python for the embedded systemjulasit
 
1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdf1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdfspshotham
 
programming language in c&c++
programming language in c&c++programming language in c&c++
programming language in c&c++Haripritha
 
Write a new version of the area calculation program that makes use of.docx
 Write a new version of the area calculation program that makes use of.docx Write a new version of the area calculation program that makes use of.docx
Write a new version of the area calculation program that makes use of.docxajoy21
 

Similar to C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx (20)

C++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdfC++ Programming Search A Linked ListThe Content of songlist.txt.pdf
C++ Programming Search A Linked ListThe Content of songlist.txt.pdf
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 
PFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdfPFB cpp code for the given problem#include iostream #include .pdf
PFB cpp code for the given problem#include iostream #include .pdf
 
constructors
constructorsconstructors
constructors
 
Python crush course
Python crush coursePython crush course
Python crush course
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
Ch 4
Ch 4Ch 4
Ch 4
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202
 
Function for python for the embedded system
Function for python for the embedded systemFunction for python for the embedded system
Function for python for the embedded system
 
Presentation
PresentationPresentation
Presentation
 
1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdf1817 LAB Playlist output linked list Given main compl.pdf
1817 LAB Playlist output linked list Given main compl.pdf
 
programming language in c&c++
programming language in c&c++programming language in c&c++
programming language in c&c++
 
Write a new version of the area calculation program that makes use of.docx
 Write a new version of the area calculation program that makes use of.docx Write a new version of the area calculation program that makes use of.docx
Write a new version of the area calculation program that makes use of.docx
 

More from BrianGHiNewmanv

Cai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docxCai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docxBrianGHiNewmanv
 
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docxCabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docxBrianGHiNewmanv
 
C++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxC++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxBrianGHiNewmanv
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
By researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docxBy researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docxBrianGHiNewmanv
 
By which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docxBy which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docxBrianGHiNewmanv
 
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docxBONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docxBrianGHiNewmanv
 
Business ethics- 12- Introduce the abuse of official position concept.docx
Business ethics- 12- Introduce  the abuse of official position concept.docxBusiness ethics- 12- Introduce  the abuse of official position concept.docx
Business ethics- 12- Introduce the abuse of official position concept.docxBrianGHiNewmanv
 
Building a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docxBuilding a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docxBrianGHiNewmanv
 
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docxBuilding a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docxBrianGHiNewmanv
 
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docxBriefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docxBrianGHiNewmanv
 
Briefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docxBriefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docxBrianGHiNewmanv
 
Brite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docxBrite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docxBrianGHiNewmanv
 
Bridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docxBridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docxBrianGHiNewmanv
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docxBrianGHiNewmanv
 
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docxBONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docxBrianGHiNewmanv
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docxBrianGHiNewmanv
 
Bob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docxBob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docxBrianGHiNewmanv
 
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docxBlood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docxBrianGHiNewmanv
 

More from BrianGHiNewmanv (20)

Cai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docxCai Corporation uses a job-order costing system and has provided the f.docx
Cai Corporation uses a job-order costing system and has provided the f.docx
 
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docxCabana Cruise Line uses a combination of debt and equity to fund opera.docx
Cabana Cruise Line uses a combination of debt and equity to fund opera.docx
 
C-{2-8-10}.docx
C-{2-8-10}.docxC-{2-8-10}.docx
C-{2-8-10}.docx
 
C++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxC++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docx
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
By researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docxBy researching online find information about 2 malware samples that we.docx
By researching online find information about 2 malware samples that we.docx
 
By which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docxBy which of the following processes are bacteria known to produce-acqu.docx
By which of the following processes are bacteria known to produce-acqu.docx
 
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docxBONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
BONUS PROBLEM ( 3 points) Ed owns 1-200 shares of ABC Corp- The compan.docx
 
Business ethics- 12- Introduce the abuse of official position concept.docx
Business ethics- 12- Introduce  the abuse of official position concept.docxBusiness ethics- 12- Introduce  the abuse of official position concept.docx
Business ethics- 12- Introduce the abuse of official position concept.docx
 
Building a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docxBuilding a strong and ethical IT policy requires the cooperation of al.docx
Building a strong and ethical IT policy requires the cooperation of al.docx
 
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docxBuilding a Project WBS and Schedule in MS Project Define Toy Requireme.docx
Building a Project WBS and Schedule in MS Project Define Toy Requireme.docx
 
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docxBriefly compare-contrast right cerebral hemisphere versus left cerebra.docx
Briefly compare-contrast right cerebral hemisphere versus left cerebra.docx
 
Briefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docxBriefly compare-contrast resting potential versus action potential- In.docx
Briefly compare-contrast resting potential versus action potential- In.docx
 
Brite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docxBrite Toothbrushes has gathered the following information to complete.docx
Brite Toothbrushes has gathered the following information to complete.docx
 
Bridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docxBridgeport Corporation engaged in the following cash transactions duri.docx
Bridgeport Corporation engaged in the following cash transactions duri.docx
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env.docx
 
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docxBONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
BONUS- If you rmoved calcium (Ca2+) from a tissue's extracellular envi.docx
 
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docxBONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
BONUS- If you removed calcium (Ca2+) from a tissue's extracellular env (1).docx
 
Bob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docxBob paid $100 for a utility bill- Which of the following accounts will.docx
Bob paid $100 for a utility bill- Which of the following accounts will.docx
 
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docxBlood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
Blood Circulation Across 1- supply blood to the upper limbs Down 3- ca.docx
 

Recently uploaded

Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 

Recently uploaded (20)

Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 

C++ 10-25 LAB- Artwork label (classes-constructors) Given main()- comp.docx

  • 1. C++ 10.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: 1881 and 1973 being the birth and death years respectively, with 1921 being the year the work was created, the output is: Ex: If the input is: the output is: Ex: If the input is: the output is: Code provided, fill in where needed on each (there is comments) .cpp or .h: main.cpp: #include "Artist.h" #include "Artwork.h" #include <iostream> #include <string> using namespace std;
  • 2. int main() { string userTitle, userArtistName; int yearCreated, userBirthYear, userDeathYear; getline(cin, userArtistName); getline(cin, userTitle); cin >> userBirthYear; cin >> userDeathYear; cin >> yearCreated; Artist userArtist = Artist(userArtistName, userBirthYear, userDeathYear); Artwork newArtwork = Artwork(userTitle, yearCreated, userArtist); newArtwork.PrintInfo(); } Artist.h: #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
  • 3. Artist.cpp: #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: #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:
  • 4. #include "Artwork.h" #include <iostream> // TODO: Define default constructor Artwork::Artwork() { title = ""; yearCreated = 0; } // TODO: Define second constructor to initialize // private fields (title, yearCreated, artist) Artwork::Artwork(string title, int yearCreated, Artist artist) { this->title = title; this->yearCreated = yearCreated; this->artist = artist; }