(project 4)Write a class for an airplane class with constructors, interface (mut
ID: 641692 • Letter: #
Question
(project 4)Write a class for an airplane class with constructors, interface (mutators and accessors)and a test driver (main). It should be able to change altitude (up,down) and speed.
The default constructor will set the altitude to 0 and speed to zero and longitude and latitude
to Boston, Massachusetts (42.3631 degrees N, 71.0064 degrees W). The overloaded constructor will set longitude and latitude to Louis Armstrong (29.9933 degrees N, 90.2581 degrees W) by passing that string to the Airplane object when it is created. If the altutude ever falls below 0 the change altutude function should announce the plane had crashed and the program exit as in the previous project. All mutators and constructor should check input for >= 0 ( no negative speeds or altitudes).
(project 5)(read the above first)
Add an external boolean equals()function that takes in two objects and returns true if they have same latlong and altitude. Write code to test it that announces a crash if equal.
Add external equalsto()function that takes in two objects and returns true if they have same latlong and altitude. The equalsto() functions is a friend function and has direct access to altitude and latlong. The objects are pass-by-reference. Write the most efficient function you can (change to pass by reference?).
(project 6)( read the above first)
Add external boolean is_equals() function that takes in two objects and returns true if they have same latlong and altitude. Write code to test it that announces a crash if equal. The is_equals() function is a friend function and has direct access to altitude and latlong. The objects are pass-by-reference AND LABELED AS CONSTANT references.
Add external boolean are_equals() function that takes in two objects and returns true if they have same latlong and altitude. Write code to test it that announces a crash if equal. The are_equals() function is NOT a friend function and has direct access to altitude and latlong. The objects are pass-by-reference AND LABELED AS CONSTANT references. Does this work? What must change to make it work? How do you get access to the member data in the classes.
i wanna do Project 6
Explanation / Answer
Airplane.h
#ifndef AIRPLANE_H
#define AIRPLANE_H
#include <iostream>
#include <cstdlib>
class Airplane {
public:
Airplane(double latitude=42.3583 , double longitude = -71.0603) :
speed(0), altitude(0), latitude(latitude), longitude(longitude) { }
double getSpeed() {return speed;}
void setSpeed(double speed) {this->speed = speed;}
void setAltitude(double altitude) {
this->altitude =altitude;
if (altitude < 0) {
cerr<<"Plane crashed."; exit(1);
}
}
double getAltitude() {return altitude:}
//same for lat and long
private:
double longitude, latitude, speed, altitude;
};
--------------------------------------------------------------------------------------------------------------------------------------------------------
This code I already had. I think it will be helpful to solve First part of ur question.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.