Redefining Base Functions (C++)
Create two simple C++ classes (Use separate files please and include appropriate headers)
Define a base class named "Venue" that holds the following member variables and functions:
Next, define a class named "Theater" that is derived from the "Venue" class, and holds the following member variables and functions:
Write a demo program to exercise these classes.
Thanks for the question.
Here is the completed code for this problem. Let me know if you
have any doubts or if you need anything to change.
Thank You !!
========================================================================================
#ifndef VENUE_H
#define VENUE_H
class Venue
{
public:
Venue(int,int,float);
// setter functions
void setYearOpened(int);
void setCapacity(int);
void
setBasePrice(float);
// getter functions
int getYearOpened() const;
float getCapacity() const;
float getBasePrice() const;
virtual float getPotentialRevenue()
;
private:
int year_opened;
int capacity;
float base_price;
float potential_revenue;
};
#endif
========================================================================================
#include "Venue.h"
Venue::Venue(int year, int capacity, float price){
this->year_opened=year;
this->capacity=capacity;
this->base_price=price;
this->potential_revenue =
this->capacity*this->base_price;
}
// setter functions
void Venue::setYearOpened(int year){
this->year_opened=year;
}
void Venue::setCapacity(int capacity){
this->capacity=capacity;
}
void Venue::setBasePrice(float price){
this->base_price=price;
}
// getter functions
int Venue::getYearOpened() const{
return this->year_opened;
}
float Venue::getCapacity() const{
return this->capacity;
}
float Venue::getBasePrice() const{
return this->base_price;
}
float Venue::getPotentialRevenue() {
this->potential_revenue =
this->capacity*this->base_price;
return this->potential_revenue;
}
========================================================================================
#ifndef THEATER_H
#define THEATER_H
#include "Venue.h"
#include <string>
using namespace std;
class Theater : public Venue
{
public:
Theater(int,int,float,string,string,string,float);
//getter functions
string getVenueName() const;
string getAddress() const;
string CityStateZip() const;
float getAverageConcession()
const;
//setter functions
void setVenueName(string);
void setAddress(string);
void setCityStateZip(string);
void
setAverageConcession(float);
virtual float getPotentialRevenue()
;
private:
string venue_name;
string address;
string city_state_zip;
float average_concession;
};
#endif
========================================================================================
#include "Theater.h"
#include "Venue.h"
#include <string>
#include <iostream>
using namespace std;
Theater::Theater(int year,int capacity,float price,string
name,string add,string cityStZip ,float avgCon):
Venue(year,capacity,price),venue_name(name),address(add),city_state_zip(cityStZip),average_concession(avgCon){
}
//getter functions
string Theater::getVenueName() const {
return venue_name;
}
string Theater::getAddress() const {
return address;
}
string Theater::CityStateZip() const {
return city_state_zip;
}
float Theater::getAverageConcession() const {
return average_concession;
}
//setter functions
void Theater::setVenueName(string name){
venue_name=name;
}
void Theater::setAddress(string addr){
address = addr;
}
void Theater::setCityStateZip(string val){
city_state_zip=val;
}
void Theater::setAverageConcession(float avgCon){
average_concession=avgCon;
}
float Theater::getPotentialRevenue() {
return
Venue::getPotentialRevenue()+average_concession*getCapacity();
}
========================================================================================
#include <iostream>
#include "Theater.h"
#include "Venue.h"
#include <string>
using namespace std;
int main(){
Venue v = Venue(1990,240,12.5);
Theater t = Theater(1990,240,12.5,"Old Memories","123
Downtown Rd","California, Washinton DC, 12345",5);
cout<<"Venue Pontential Revenue:
$"<<v.getPotentialRevenue()<<endl;
cout<<"Theaters Pontential Revenue:
$"<<t.getPotentialRevenue()<<endl;
}
========================================================================================
Redefining Base Functions (C++) Create two simple C++ classes (Use separate files please and include appropriate...
Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...
Language: C++ Create an abstract base class person. The person class must be an abstract base class where the following functions are abstracted (to be implemented in Salesman and Warehouse): • set Position • get Position • get TotalSalary .printDetails The person class shall store the following data as either private or protected (i.e., not public; need to be accessible to the derived classes): . a person's name: std::string . a person's age: int . a person's height: float The...
USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables: description: A string that holds a brief description of the item. unitsOnHand: An int that holds thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...
.Your solution must include header, implementation file, and test files .In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. In a well-designed system, these would be derived from a common class, Figure. You are to...
Please show it in C++. Thank you! Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...
C++ Program 1a. Purpose Practice the creation and use of a Class 1b. Procedure Write a class named Car that has the following member variables: year. An int that holds the car’s model year. make. A string object that holds the make of the car. speed. An int that holds the car’s current speed. In addition, the class should have the following member functions. Constructor. The constructor should accept the car’s year and make as arguments and assign these values...
its about in C++ You will implement a simple calendar application The implementation should include a class named Calendar, an abstract class named Event and two concrete classes named Task and Appointment which inherit from the Event class The Event Class This will be an abstract class. It will have four private integer members called year, month, day and hour which designate the time of the event It should also have an integer member called id which should be a...
Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...
Ship, CruiseShip, and CargoShip Classes (in C++ language i use visual studios to code with) design a Ship class that has the following members: - A member variable for the name of the ship (a string) - A member variable for the year that the ship was built (a string) - A contsructor and appropriate accessors and mutators - A virtual print function that displays the ship's name and the year it was built (nobody seems to get this part...
Answer this in c++ #include <iostream> #include <fstream> #include <string> using namespace std; class Person { public: Person() { setData("unknown-first", "unknown-last"); } Person(string first, string last) { setData(first, last); } void setData(string first, string last) { firstName = first; lastName = last; } void printData() const { cout << "\nName: " << firstName << " " << lastName << endl; } private: string firstName; string lastName; }; class Musician : public Person { public: Musician() { // TODO: set this...