Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; class Art{ protected: string title; float price; int year; public: Art(); Art(string n, float p,int y); void setYear(int y); void

#include #include using namespace std;

class Art{ protected: string title; float price; int year; public: Art(); Art(string n, float p,int y); void setYear(int y); void setTitle(string t); int getYear(); string getTitle(); virtual string GetType() = 0; // "Painting" or "Statue" virtual float getPrice() = 0; virtual void printInfo(){ cout

#include "Art.cpp"

class Painting : public Art{ int width; int height; int color; public: Painting(); Painting(string n,float p,int y,int w,int h,int c); void setValues(string n,float p,int y,int w,int h,int c); int getWidth(); int getHeight(); string getColor(); string GetType(); float getPrice(); void printInfo(); };

image text in transcribed

Question 4: Polymorphism (27 points) Assume you have all three classes from previous question (Art, Paintings, and Statues) are implemented correctly and ready to use (with setValues and getters functions). Write down the implementation of the following: 2. A global function Art Create Art(). The functions ask the user about the type of the art he wants to create, then reads the information based on the type of selected art (Painting or Statue) creates an object and returns a pointer to the newly created object using Art pointer. (5 points) 3 A main function. Inside it, do the following two things: (5 points) 1. The function creates an array of pointers to Art class of size 6. Name your array myArt. 2. Create 6 art objects using the CreateArt function and store them in myArtarray. 4 Define a new class called Museum, use this class to track the arts a museum has. The class needs two member variables: arts_data which is an array of type Art*, and a count to track how many art objects do we have. Assume that the museum cannot have more than 100 arts. Define two member functions: a. void AddArt() which calls the global function Create Art defined in Part (A) of this question to add a new art to the museum arts_data array. (3 points) b. Painting GetMost Expensive Painting which returns a pointer to the painting object of highest price in the museum, if there was no painting object, it should retum NULL. Note: you should compare only paintings objects not statues. (6 points) c. float GetTotal() which returns the total price of all art objects in the museum. (4 points) d. bool HasMoreArtValue (Museum&M2) which comparesthe original museum object with M2 object and returns true of original object has more total value. ( 4 points) Question 4: Polymorphism (27 points) Assume you have all three classes from previous question (Art, Paintings, and Statues) are implemented correctly and ready to use (with setValues and getters functions). Write down the implementation of the following: 2. A global function Art Create Art(). The functions ask the user about the type of the art he wants to create, then reads the information based on the type of selected art (Painting or Statue) creates an object and returns a pointer to the newly created object using Art pointer. (5 points) 3 A main function. Inside it, do the following two things: (5 points) 1. The function creates an array of pointers to Art class of size 6. Name your array myArt. 2. Create 6 art objects using the CreateArt function and store them in myArtarray. 4 Define a new class called Museum, use this class to track the arts a museum has. The class needs two member variables: arts_data which is an array of type Art*, and a count to track how many art objects do we have. Assume that the museum cannot have more than 100 arts. Define two member functions: a. void AddArt() which calls the global function Create Art defined in Part (A) of this question to add a new art to the museum arts_data array. (3 points) b. Painting GetMost Expensive Painting which returns a pointer to the painting object of highest price in the museum, if there was no painting object, it should retum NULL. Note: you should compare only paintings objects not statues. (6 points) c. float GetTotal() which returns the total price of all art objects in the museum. (4 points) d. bool HasMoreArtValue (Museum&M2) which comparesthe original museum object with M2 object and returns true of original object has more total value. ( 4 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

l List elements to consider when developing an employee handbook.

Answered: 1 week ago