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, 21.06.2019 18:30
An attribute on a webpage allows you to set borders and change background colors. true or false
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Write the html code to make a link out of the text “all about puppies”. it should link to a pdf called “puppies.pdf” inside the “documents” folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
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, 16.12.2020 19:00
question
Geography, 16.12.2020 19:00
Questions on the website: 13722363