bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 15, Problem 2PP

Create 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 below). 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, accessor, and mutator member functions, an overloaded assignmentoperator, and a copy constructor. Write a driver program that tests all your member functions.

The definition of the class Person follows. The implementation of the classis 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;

};

Blurred answer
Students have asked these similar questions
Take the tax program from the last homework assignment and implement it using classes and objects instead. To do so, create a class definition for a class called Customer with attributes income and tax. It should also have a set method for income, and a calcTax() method to assign tax and return it. As a reminder, the tax is calculated as follows:  Income  Tax Due  $0 - $50,000 5%   $50,000-$100,000  $2,500 + 10% of (income > $50,000)  > $100,000  $7,500 + 15% of (income > $100,000) Create a Customer object in main, have the user enter the income and assign this to the income variable of the Customer object, and then call the calcTax() method for the Customer object and print the tax due.
Write a class encapsulating the concept of the weather forecast, assuming that it has the following attributes: the temperature and the sky conditions (e.g. sunny, snowy, cloudy, rainy, etc.).  Include a default constructor, an overloaded constructor, accessors and mutators, and the methods, toString() and equals(). Temperature, in Fahrenheit, should be between -50 and +150; the default value is 70, if needed. The default sky condition is sunny. In Addition, include a method that converts Fahrenheit to Celsius. Celsius temperature = (Fahrenheit temperature – 32) * 5/9. Also include a boolean method that checks whether the weather attributes are consistent (there are two cases where they are not consistent: when the temperature is below 32 and it is not snowy, and when the temperature is above 100 and it is not sunny). Write a client class to test all the methods in your class.
Design a class called "Person" with attributes for name, age, and gender. Implement methods to get and set these attributes, and also a method to calculate the person's age in dog years (assuming 1 dog year is equivalent to 7 human years).

Chapter 15 Solutions

Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY