Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Input file: Truck1 CityFire Helo1 ForrestFire LAX Objectives: 1) Use inheritance to derive new classes; 2) Understand abstract base classes; 3) Use base class functions

image text in transcribedimage text in transcribedimage text in transcribed

Input file:

Truck1 CityFire Helo1 ForrestFire LAX
Objectives: 1) Use inheritance to derive new classes; 2) Understand abstract base classes; 3) Use base class functions from a derived class; 4) Override base class virtual functions; 5) Define base class pure virtual functions; 6) Understand static and dynamic function call binding; Project description: In this assignment you will create a class representing a generic firefighting vehicle (FFVehicle), and two additional classes that inherit from this class, the FFTruck and FF Helicopter classes. The project is geared toward giving you practical experience with characteristics and C++ implementation details of inheritance and polymorphism. Requirements: 1. Your program must be split into 7 files. There will be 3 classes (each with separate interface and implementation files), and a driver file. The requirements for these are specified below: a) The FFVehicle class - This is an abstract class . . Files must be named ffvehicle.h and ffvehicle.cpp Class must be named FFVehicle Must contain #include guards for FFVEHICLE_H Must have these protected members i. A string containing the vehicle's name ii. A string containing the name of the fire's location Must have these public members i. A one parameter constructor that takes the vehicle's name. ii. A one parameter virtual void function, gotoFire, with a string parameter representing the fire location. Sets the fire location data member and outputs: responding to fire. (see sample output) iii. A virtual void function, douse Fire, that outputs: fire extinguished. (see sample output) iv. A parameterless pure-virtual void function, getWater that captures how each type of vehicle gets water to fight the fire. b) The FFTruck class - This is a derived class that inherits from the FFVehicle class as public . Files must be named fftruck.h and fftruck.cpp Class must be named FFTruck Must contain #include guards for FFTRUCK_H Has no private members . Must have these public members i. A one parameter constructor that takes a string (the truck's vehicle name) - This constructor must pass this parameter to the base class constructor. ii. A function, getWater, that overrides/ implements the pure virtual function in the base class and outputs: hydrants connected. (see sample output) iii. A void function, douseFire, that overrides the virtual function in the base class, and outputs: pump pressure OK. (see sample output) Upon outputting this statement, this functions calls the douse Fire function in the base class (which reports that the fire is extinguished) c) The FFHelicopter class - This is a derived class that inherits from the FFVehicle class as public . . . Files must be named ffhelicopter.h and ffhelicopter.cpp Class must be named FFHelicopter Must contain #include guards for FFHELICOPTER_H Has one private data member: a string that represents the helicopter's staging airport. Must have these public members i. A two-parameter constructor that takes a string for the helicopter's vehicle name, and a string representing the staging airport in this order). This constructor passes the vehicle name parameter to the base class constructor and uses the second parameter to set its staging site data member. ii. A void function, gotoFire, that overrides the virtual function in the base class, and: 1) sets the fire location name; and 2) outputs: staging in for fire. (see sample output) iii. A function, getWater, that overrides/ implements the pure virtual function in the base class and outputs: scooping water from lake. (see sample output) d) A driver, or client, file . . Must be named proj4.cpp Must have two functions as shown below-main must be defined first o fightFire - This void function simulates the three stages of fighting a fire: 1) going to the fire (or staging site); 2) getting watter; and 3) dousing the fire with a single function call It has two parameters: 1) a reference to a FFVehicle object; and 2) a string for the location of the fire. It invokes three functions (with appropriate parameters) using the reference: 1. gotoFire 2. getWater 3. douse Fire o 3. douse Fire main - This function performs Must be defined first Opens and reads an input file named fires.txt, in this format (see sample input file): 1. Line 1: Name of the truck firefighting vehicle 2. Line 2: Location name of fire to be fought by the truck 3. Line 3: Name of the helicopter firefighting vehicle 4. Line 4: Location name of fire to be fought by the helicopter 5. Line 5: Name of the staging airport for the helicopter Instantiates a FFTruck object with the information from the input file, and invokes the fightFire function (with the FFTruck object as an argument) Instantiates a FFHelicopter object with the information from the input file, and invokes the fightFire function (with the FFHelicopter object as an argument) 2. Sample output (based on sample input file provided with this assignment) - Your output must match. Do not add additional verbiage, or change line spacing or character spacing (do not use tabs - only a single space between items). Check your spelling. See sample output below: Truck1 responding to cityFire fire. Trucki hydrants connected. Truck1 pump pressure OK. cityFire fire extinguished. Helol staging in Lax for Forrestfire fire. Helol scooping water from lake. Forrestfire fire extinguished

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago