answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olya-2409 [2.1K]
2 years ago
3

Reate a base class called Vehicle that has the manufacturer’s name (type string ), number of cylinders in the engine (type int )

, and owner (type Person given in the code that follows). Then create a class called Truck that is derived from Vehicle and has additional properties, the load capacity in tons (type double since it may contain a fractional part) and towing capacity in pounds (type int ). Be sure your classes have a reasonable complement of constructors and accessor methods, an overloaded assignment operator, and a copy constructor. Write a driver program that tests all your methods.
The definition of the class Person follows. The implementation of the class is part of this programming project.

class Person

{

public:

Person( );

Person(string theName);

Person(const Person& theObject);

string getName( ) const;

Person& operator=(const Person& rtSide);

friend istream& operator >>(istream& inStream, Person& personObject);

friend ostream& operator <<(ostream& outStream, const Person&

personObject);

private:

string name;

};
Computers and Technology
1 answer:
PilotLPTM [1.2K]2 years ago
7 0

Answer:

Explanation:

class Person

{

public:

Person();

Person(string theName);

Person(const Person& theObject);

string get_name() const;

Person& operator=(const Person& rtSide);

friend istream& operator >>(istream& inStream,Person& personObject);

friend ostream& operator <<(ostream& outStream,Person& personObject);

private:

string name;

};

Person::Person()

{

 

}

Person::Person(string theName)

{

this->name=theName;

}

Person::Person(const Person& theObject)

{

name=theObject.name;

}

string Person::get_name() const

{

return name;

}

Person& Person::operator=(const Person& rtSide)

{

name=rtSide.name;

return *this;

}

istream& operator >>(istream& inStream,Person& personObject)

{

cout<<"Enter Person Name :";

getline(inStream,personObject.name);

return inStream;

}

ostream& operator <<(ostream& outStream,Person& personObject)

{

outStream<<"Name :"<<personObject.get_name()<<endl;

return outStream;

}

//================================

// Declaration of Vehicle Class

//================================

class Vehicle

{

public:

Vehicle();

Vehicle(string m, int cyl, Person p);

Vehicle(const Vehicle& theObject);

string getManufacturer() const;

int getCylinders() const;

Person getOwner() const;

void setManufacturer(string maker);

void setCylinders(int cylinders);

void setOwner (Person p);

void output();

// Outputs the data members of the class appropriately labeled

Vehicle& operator=(const Vehicle& rtSide);

private:

string manufacturer;

int numCylinders;

Person owner;

};

Vehicle::Vehicle()

{

 

}

Vehicle::Vehicle(string m, int cyl, Person p)

{

this->manufacturer=m;

this->numCylinders=cyl;

this->owner=p;

}

Vehicle::Vehicle(const Vehicle& theObject)

{

this->manufacturer=theObject.getManufacturer();

this->numCylinders=theObject.getCylinders();

this->owner=theObject.getOwner();

}

string Vehicle::getManufacturer() const

{

return manufacturer;

}

int Vehicle::getCylinders() const

{

return numCylinders;

}

Person Vehicle::getOwner() const

{

return owner;

}

void Vehicle::setManufacturer(string maker)

{

this->manufacturer=maker;

}

void Vehicle::setCylinders(int cylinders)

{

this->numCylinders=cylinders;

}

void Vehicle::setOwner (Person p)

{

this->owner=p;

}

void Vehicle::output()

{

cout<<"Person Name :"<<owner.get_name()<<endl;

cout<<"Manufacturer :"<<manufacturer<<endl;

cout<<"Number of Cylinders :"<<numCylinders<<endl;

}

// Outputs the data members of the class appropriately labeled

Vehicle& Vehicle::operator=(const Vehicle& rtSide)

{

owner=rtSide.owner;

manufacturer=rtSide.getManufacturer();

numCylinders=rtSide.getCylinders();

return *this;

}

//===============================

// Declaration of Truck Class

//===============================

class Truck : public Vehicle

{

public:

Truck();

Truck(string m, int cyl, Person p, double load, int tow);

Truck(const Truck& theObject);

double getLoadCapacity() const;

int getTowingCapacity() const;

void setLoadCapacity(double newLoad);

void setTowingCapacity(int newTowing);

void output();

// Outputs the data members appropriately labeled.

Truck& operator=(const Truck& rtSide);

private:

double loadCapacity;

int towingCapacity;

};

Truck::Truck()

{

 

}

Truck::Truck(string m, int cyl, Person p, double load, int tow):Vehicle(m,cyl,p)

{

this->loadCapacity=load;

this->towingCapacity=tow;

}

Truck::Truck(const Truck& theObject)

{

this->loadCapacity=theObject.loadCapacity;

this->towingCapacity=theObject.towingCapacity;

}

double Truck::getLoadCapacity() const

{

return loadCapacity;

}

int Truck::getTowingCapacity() const

{

return towingCapacity;

}

void Truck::setLoadCapacity(double newLoad)

{

this->loadCapacity=newLoad;

}

void Truck::setTowingCapacity(int newTowing)

{

this->towingCapacity=newTowing;

}

void Truck::output()

{

Vehicle::output();

cout<<"Load Capacity :"<<loadCapacity<<endl;

cout<<"Towing Capacity :"<<towingCapacity<<endl;

}

// Outputs the data members appropriately labeled.

Truck& Truck::operator=(const Truck& rtSide)

{

this->loadCapacity=rtSide.getLoadCapacity();

this->towingCapacity=rtSide.getTowingCapacity();

}

int main ()

{

Person p("James");

Vehicle v("Toyota",4,p);

cout<<"Displaying Vehicle Info:"<<endl;

v.output();

Person p1("Williams");

Truck t1("Maruthi",4,p1,4500,2500);

cout<<"\nDisplaying Truck Info:"<<endl;

t1.output();

return 0;

You might be interested in
For any element in keysList with a value greater than 60, print the corresponding value in itemsList, followed by a semicolon (n
nika2105 [10]

Answer:

Below are the python Program for the above question:

Explanation:

keysList =[1,61,68,64]#key list items.

itemsList =[1,2,3,4]#item list items.

for x in range(len(keysList)):#for loop.

   if(keysList[x]>60):#check the value to be greator.

       print(itemsList[x],end=";")#print the value.

Output:

  • The above code will print as "2;3;4;".

Code Explanation:

  • The above code is in python language, in which the first and second line of the code defines a list. That list can be changed by the user when he wants.
  • Then there is a or loop that scans the keylist items and matches the items that it is greater than 60 or not. If it then takes the location and prints the itemlist by the help of that location.
6 0
2 years ago
Read 2 more answers
Which of the following is a collection of unprocessed items, which can include text, numbers, images, audio, and video?A. DataB.
Tema [17]

Answer:

Option A is the correct answer for the above question.

Explanation:

Data can be defined as raw fact which can be useful when it will be processed. The processed data can be formed as information. The data can be anything. It can b e text or audio or images or video. The above question asked about the term which is an unprocessed item and can form information after processing. Then the answer is Data which stated from the option A. So Option A is the correct answer while the other is not because--

  • Option B states about instruction which is useful to process the data.
  • Option C states about Programs that can be formed when one or more instruction is grouped.
  • Option D states about the information that the user can get after processed the data.

6 0
2 years ago
The height of a small rocket y can be calculated as a function of time after blastoff with the following piecewise function: y 5
SOVA2 [1]

Answer:

High level Language

understand

Explanation:

rocket is 0...4433456u888

5 0
1 year ago
. When you have multiple graphics positioned on a page, you can _______________ them so that they are a single graphic instead o
alisha [4.7K]
The best answer is B
i hope its help
8 0
2 years ago
You have verified that all your wireless settings are correct. What is most likely the problem if your laptop has recently been
alukav5142 [94]

Answer:

D) The antenna connector is not connected properly

Explanation:

The antenna of a laptop is inside the laptop and it is the antenna that gives access to wireless connection.Since the laptop has just been serviced, the antenna connector could have been inadvertently disconnected hence the antenna would not be able to function and wireless connectivity would not work.

8 0
2 years ago
Other questions:
  • An asterisk (*) following a cell reference in a formula is the arithmetic operator that directs excel to perform the division op
    7·1 answer
  • An administrator has initiated the process of deploying changes from a sandbox to the production environment using the Force IDE
    5·1 answer
  • Why is it important for a Support Agent to understand and follow their company’s standardized case lifecycle roadmap? (Select 2)
    12·1 answer
  • Tina reported a safety hazard at her workplace to OSHA. Representatives from OSHA
    5·1 answer
  • The expression 10,785(1.0275)x represents the amount of money in an investment account with interest that compounds annually for
    14·2 answers
  • Write the definition of a function printAttitude, which has an int parameter and returns nothing. The function prints a message
    14·1 answer
  • Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest
    13·2 answers
  • Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?
    10·1 answer
  • You know that you should check the room for security against unwanted entry do you check locks on doors and windows. What else d
    15·1 answer
  • Describe how a cell’s content and format attributes are related.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!