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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY