C++ Program Use the FlightInfo class in the attached FlightInfo.h file for this assignment. Task 1: Modify the FlightInfo.h file to include the following (empty) Exception Classes. Invalid Direction Invalid Fuel Level Invalid Altitude Invalid Speed Modify the setter methods to throw an exception for invalid data. Note that these setters are void. They create exceptions instead of returning a value for invalid data. Task 2: Create a driver program that will instantiate a FlightInfo object. Driver Program steps. Prompt the user for the following inputs values Speed Direction Altitude Fuel Level Call the flightInfo's showAll() method. Catch these exceptions in the driver program and display a message anytime invalid data is given indicating the issue. The valid ranges are commented in the FlightInfo.h file. As usual, work on a small section like Invalid Direction and confirm that works as expected. Once that is good, the rest are very similar. 6 point Bonus. Create an additional Exception Class named FuelWarning if the Fuel < 10 and Altitude > 1000. Throw this exception where appropriate and catch in the driver program. FlightInfo.h: #ifndef FlightInfo_H #define FlightInfo_H #include using namespace std; class FlightInfo { private: int absoluteAltitude = 0; int speed = 0; int fuelLevel = 0; int direction = 0; public: // setters //valid 0-10000 void setAbsoluteAltitude(int alt) { absoluteAltitude = alt; }    //valid 0 - 650 void setSpeed(int currentSpeed) { speed = currentSpeed; }    // Valid 0 - 100 void setFuelLevel(int level) { fuelLevel = level; }    // valid 0-360 void setDirection(int heading) { direction = heading; } // getters int getAbsoluteAltitude() { return absoluteAltitude; } int getSpeed() { return speed; } int getFuelLevel() { return fuelLevel; } int getDirection() { return direction; } void showAll() { cout <<"Altitude = " << getAbsoluteAltitude() << endl; cout <<"Speed = " << getSpeed() << endl; cout <<"FuelLevel = " << getFuelLevel() << endl; cout <<"Direction = " << getDirection() << endl; } }; #endif

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++ Program

Use the FlightInfo class in the attached FlightInfo.h file for this assignment.


Task 1: Modify the FlightInfo.h file to include the following (empty) Exception Classes.

  1. Invalid Direction
  2. Invalid Fuel Level
  3. Invalid Altitude
  4. Invalid Speed
  5. Modify the setter methods to throw an exception for invalid data. Note that these setters are void. They create exceptions instead of returning a value for invalid data.

Task 2: Create a driver program that will instantiate a FlightInfo object.

Driver Program steps.

  1. Prompt the user for the following inputs values
    1. Speed
    2. Direction
    3. Altitude
    4. Fuel Level
  2. Call the flightInfo's showAll() method.
  3. Catch these exceptions in the driver program and display a message anytime invalid data is given indicating the issue. The valid ranges are commented in the FlightInfo.h file.

As usual, work on a small section like Invalid Direction and confirm that works as expected. Once that is good, the rest are very similar.

6 point Bonus. Create an additional Exception Class named FuelWarning if the Fuel < 10 and Altitude > 1000. Throw this exception where appropriate and catch in the driver program.

FlightInfo.h:

#ifndef FlightInfo_H
#define FlightInfo_H

#include <iostream>
using namespace std;


class FlightInfo
{
private:
int absoluteAltitude = 0;
int speed = 0;
int fuelLevel = 0;
int direction = 0;
public:

// setters

//valid 0-10000
void setAbsoluteAltitude(int alt) {
absoluteAltitude = alt;
}
  
//valid 0 - 650
void setSpeed(int currentSpeed) {
speed = currentSpeed;
}
  
// Valid 0 - 100
void setFuelLevel(int level) {
fuelLevel = level;
}
  
// valid 0-360
void setDirection(int heading) {
direction = heading;
}

// getters
int getAbsoluteAltitude() {
return absoluteAltitude;
}
int getSpeed() {
return speed;
}
int getFuelLevel() {
return fuelLevel;
}
int getDirection() {
return direction;
}


void showAll() {
cout <<"Altitude = " << getAbsoluteAltitude() << endl;
cout <<"Speed = " << getSpeed() << endl;
cout <<"FuelLevel = " << getFuelLevel() << endl;
cout <<"Direction = " << getDirection() << endl;
}
};

#endif

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
Exception Handling Keywords
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education