subject
Computers and Technology, 22.07.2020 16:01 peno211

Starting with what you wrote for an exercise in this module, add two new public constant data members. Riders know the indexes of their start and destination floors. This is useful because now those indexes can be turned into actual Floor objects. Name the new members goingUp and goingDown -- both constant bool s. Set them in the constructor by comparing the start and destination floors (based on their elevations). Remember that Floor objects have the type conversion operator? Use that. Access the floors like this: Building::floors[to] and Building::floors[from] . Those are the actual Floor objects corresponding to those indexes, so you can compare their elevations using operator-less-than. Yes, if (Building::floors[to] < Building::floors[from]) works even though you did not write such an operator -- it uses type conversion!
Modify the assignment operator to include the two newly added constant bool s. That's it -- the Rider class is completely finished!
//My Code:
//Rider. h
#ifndef Rider_h
#define Rider_h
#include
#include
struct Rider
{
const int to;
const int from;
const bool goingUp;
const bool goingDown;
Rider(int , int);
Rider& operator=(const Rider&);
};
#endif /* Rider_h */
//Rider. cpp
#include
#include "Rider. h"
#include "Building. h"
using namespace std;
Rider::Rider(int from, int to)
: from(from), to(to), goingDown(Building::floors[to] < Building::floors[from]), goingUp(Building::floors[to] > Building::floors[from])
{}
Rider& Rider::operator=(const Rider& copyThis) {
if (this != ©This) {
const_cast(this->to) = copyThis. to;
const_cast(this->from) = copyThis. from;
const_cast(this->goingUp) = copyThis. goingUp;
const_cast(this->goingDown) = copyThis. goingDown;
}
return *this;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:00
Create a cell reference in a formula by typing in the cell name or         a. right-clicking the cell. b. clicking the cell. c. clicking the column where the cell is located. d. clicking the row where the cell is located.
Answers: 1
question
Computers and Technology, 22.06.2019 15:00
The three logical operators used to write compound conditions are "and," "or," and "not." a: true b: false
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
Answers: 1
question
Computers and Technology, 24.06.2019 05:50
What all vehicles has tesla inc. created over the years
Answers: 3
You know the right answer?
Starting with what you wrote for an exercise in this module, add two new public constant data member...
Questions
question
Mathematics, 01.12.2020 06:30
question
Mathematics, 01.12.2020 06:30
question
Mathematics, 01.12.2020 06:30
question
Mathematics, 01.12.2020 06:30
Questions on the website: 13722361