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
Howard is designing a chair swing ride. the swing ropes are 5 meters long, and in full swing they tilt in an angle of 29° outside chairs to be 2.75 m above the ground in full swing.
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
Which option correctly describes a dbms application? a. software used to manage databases b. software used to organize files and folders c. software used to develop specialized images d. software used to create effective presentations
Answers: 1
question
Computers and Technology, 23.06.2019 16:50
15: 28read the summary of "an indian's view of indian affairs."15 betterin "an indian's view of indian affairs," it is asserted that conflicts could be reduced if white americansunderstood native americans..pswhich of the following would make this summary more complete? eleo the fact that chief joseph believes the great spirit sees everythinthe fact that chief joseph was born in oregon and is thirty-eight years oldo the fact that chief joseph states that he speaks from the hearthehehethe fact that chief joseph of the nez percé tribe made this claimebell- ==feetle===-felsefe ==submitmark this and retum.=
Answers: 3
question
Computers and Technology, 24.06.2019 18:30
How does the use of e-mail benefit business communications? it can be sent at any time. it is faster than regular mail. it improves writing skills. it is less expensive than using a courier. it reduces the need for proofreading.
Answers: 1
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
English, 22.03.2021 22:40
question
Mathematics, 22.03.2021 22:40