Question

Write the declaration for class Building. The class’s members should be: doors, an integer. This variable...

Write the declaration for class Building. The class’s members should be:

doors, an integer. This variable should not be accessible to code outside the class or to member functions in any class derived from class Building.
steps, an integer. This variable should not be accessible to code outside the class, but should be accessible to member functions in any class derived from class Building.
setDoors, getDoors, setSteps, and getSteps. These are the set and get functions for the member variables doors and steps. These functions should be accessible to code outside the class.
counterBuildingItem, a public virtual member function that returns the value of doors times steps.
total, a public pure virtual member function that accepts two integers as its parameters.


Next write the declaration for class Dugout (non-abstract/concrete class), which is derived from class Building. The class’s members should be:

holes, a float. This variable should not be accessible to code outside the class but should be accessible to member functions in any class derived from class Dugout.
windows, a float. This variable should not be accessible to code outside the class, but should be accessible to member functions in any class derived from class Dugout.
setHoles, getHoles, setWindows, and getWindows. These are the set and get functions for the member variables holes and windows. These functions should be accessible to code outside the class.
counterBuildingItem, a public member function that overrides the base class counterBuildingItem function. This function should return the value of holes times windows.
total, a public member function that implements the base class total function. This function should return the total of the two parameters.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;

class Building
{
protected :
   int doors;
   int steps;
  
public :  
Building()
{
  
   }
  
void setDoors(int doors)
{
   this->doors=doors;
   }
   int getDoors()
   {
       return doors;
   }
   void setSteps(int steps)
   {
      this->steps=steps;
   }
   int getSteps()
   {
       return steps;
   }
  
   virtual float counterBuildingItem()
   {
       return doors*steps;
   }
   virtual int total(int a,int b)=0;
  
};


class Dugout : public Building
{
protected :
    float holes;
    float windows;
   
public :  
Dugou()
{
   
   }
   void setHoles(float holes)
   {
      this->holes=holes;
   }
   float getHoles()
   {
      return holes;
   }
   void setWindows(float windows)
   {
      this->windows=windows;
   }
   float getWindows()
   {
      return windows;
   }
     
   float counterBuildingItem()
   {
      return holes*windows;
   }
     
   int total(int a,int b)
   {
      return a+b;
   }
     
};
int main() {
Dugout d;
d.setSteps(30);
d.setDoors(8);
d.setWindows(5.5);
d.setHoles(8.5);

cout<<"\nDugOut Info ::"<<endl;
cout<<"Steps :"<<d.getSteps()<<endl;
cout<<"Doors :"<<d.getDoors()<<endl;
cout<<"Counter Building Item :"<<d.counterBuildingItem()<<endl;
cout<<"Total :"<<d.total(5,11)<<endl;
  
   return 0;
}
_____________________________

Output:


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Write the declaration for class Building. The class’s members should be: doors, an integer. This variable...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In JAVA Algorithm Workbench 1. Write the first line of the definition for a Poodle class....

    In JAVA Algorithm Workbench 1. Write the first line of the definition for a Poodle class. The class should extend the Dog class. 2. Look at the following code, which is the first line of a class definition: public class Tiger extends Felis In what order will the class constructors execute? 3. Write the statement that calls a superclass constructor and passes the arguments x, y, and z. 4. A superclass has the following method: public void setValue(int v) value...

  • Write a class declaration named Circle with a private member variable named radius.

    CODE IN C++Write a class declaration named Circle with a private member variable named radius. Write set and get functions to access the radius variable, and a function named getArea that returns the area of the circle. The area is calculated as 3.14159 * radius * radius. Add a default constructor the Circle class. The constructor should initialize the radius member to 0. Add an overloaded constructor to the Circle class. The constructor should accept an argument and assign radius...

  • Write a class declaration named Circle with a private member variable named radius.

     in C++ Write a class declaration named Circle with a private member variable named radius. Write set and get functions to access the radius variable, and a function named getArea that returns the area of the circle. The area is calculated as 3.14159*radius*radius. Add a default constructor to the Circle class. The constructor should initialize the radius member to 0. Add an overloaded constructor to the Circle class. The constructor should accept an argument and assign its value to the radius...

  • 8. Suppose class D is derived from class B, and class B has a public member...

    8. Suppose class D is derived from class B, and class B has a public member function that is virtual whose declaration is virtual void fO:, and another publie member function that is not virtual whose declaration is void g):. Suppose class D has its own version of the two functions void 1() and void gO. Here below is a pointer definition and access to the member functions f) and gO Suppose this is embedded in an otherwise correct and...

  • A. (C++) Write a class declaration named Circle, with a private member variable, radius. Write set...

    A. (C++) Write a class declaration named Circle, with a private member variable, radius. Write set and get functions to access the radius variable, and a function named get getArea which returns the area of the circle. The area is calculated as 3.14 * radius * radius. B. Write a constructor to the circle that accepts an argument and assign its value to the radius member variable. C. Add a static member variable that accounts for the currently active circle...

  • C++ Program 2 Consider a class Employee with data members: age (an integer), id (an integer)...

    C++ Program 2 Consider a class Employee with data members: age (an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class Employee { private: int age; int id; float salary: public: Employee; // default constructor: age=0, id=0, and salary=0 void setAge(int x); // let age = x void setId(int x); // let id = x void setSalary(float x); // salary = x int getAge(); // return age int getId; // return id float...

  • This Program should run in C++ In an effort to develop in-depth knowledge of base class, derived class, and operator overloading, we will expand on our in-class exercise of developing the rectangleTyp...

    This Program should run in C++ In an effort to develop in-depth knowledge of base class, derived class, and operator overloading, we will expand on our in-class exercise of developing the rectangleType class and overload the following operators: +, -, *, ++, --, ==, !=, >>, and <<. Your program should contain the following features: a. Create a base class named rectangleType with following private data members: • length with double type • width with double type b. rectangleType class...

  • Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...

    Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...

  • Question 1 10 pts Inheritance is a capability of C++ to represent increased specialization that is...

    Question 1 10 pts Inheritance is a capability of C++ to represent increased specialization that is often found in real world relationships. True False Question 2 10 pts Inheritance between a child and parent object exhibits an 'relationship. Question 3 10 pts As you move down an inheritance relationship from parent to child, you typically move from a general to specific description. True False Question 4 10 pts The syntax for declaring DerivedClass to publicly inherit from BaseClass is given...

  • Create a class hierarchy to be used in a university setting. The classes are as follows:...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT