subject

Write the class RoadSegmet. The class inherits from Transportation Class. The Class have a vector hourlySpeeds data field which will hold the speed for all 24 hours of the day (each index is 1 hour). You will be able to set a speed for a specific hour, or all 24 speeds at once using setHourSpeed(unsigned hour, double speed) or setAllHourSpeeds(const vector &) respectively.

The length of time on the road segment is calculated by taking it's distance and dividing by the speed at the time of departure. This length of time is then added to the departureTime parameter to get the arrivalTime.

Define a RiverSegment class that inherits from the base TransportationClass from above. This class will have a vector scheduledDepartureTimes data field that will keep track of the departure time (e. g. 10.5 represents the time 10:30) of all ferries on the river. You can assume these are sorted. Additionally, there is a _speed value that is the speed of the ferry at all times (ferries tend to be consistently slow). There is a setSpeed function to change the _speed value. Additionally, there is an addDepartureTime(double hour) function to add a departure time to the vector. Make sure the time are sorted

Computing the arrival time for the RiverSegment is a little more complicated since you need to wait for the next available departure time. Once you find the next available departure time (after the departure time passed in), you need to add the length of time on the river segment. This is done by dividing the _distance by the _speed. Add the time on the river to the departure time (from the vector of departure times) and this will give you the arrive time.

note: If there is no departure time scheduled for after your planned departure, you need to take the first available departure the following day. Our solution assumes the departure times are the same every day.

TransportationLink. h

#include

using namespace std;

#ifndef __TRANSPORTATIONLINK_H__
#define __TRANSPORTATIONLINK_H__

const int HOURS_PER_DAY = 24;
const int MINS_PER_HOUR = 60;
const int MINS_PER_DAY = MINS_PER_HOUR * HOURS_PER_DAY; //24 * 60

class TransportationLink {
protected:
string _name;
double _distance;

public:
TransportationLink(const string &, double);
const string & getName() const;
double getDistance() const;
void setDistance(double);

// Passes in the departure time (as minute) and returns arrival time (as minute)
// For example:
// 8 am will be passed in as 480 (8 * 60)
// 2:30 pm will be passed in as 870 (14.5 * 60)
virtual unsigned computeArrivalTime(unsigned minute) const = 0;
};

#endif

TransportationLink. cpp

#include "TransportationLink. h"

#include

using namespace std;

TransportationLink::TransportationL ink(const string &name, double distance)
: _name(name), _distance(distance)
{}

const string & TransportationLink::getName() const {
return _name;
}

double TransportationLink::getDistance() const {
return _distance;
}

void TransportationLink::setDistance(dou ble distance) {
_distance = distance;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:40
Develop a function to create a document in the mongodb database “city” in the collection “inspections.” be sure it can handle error conditions gracefully. a. input -> argument to function will be set of key/value pairs in the data type acceptable to the mongodb driver insert api call b. return -> true if successful insert else false (require a screenshot)
Answers: 2
question
Computers and Technology, 23.06.2019 04:00
Laire writes a letter to her grandmother, in which she describes an amusement park she visited last week. she adds pictures of that place in her letter. which feature of a word processing program will claire to remove unwanted parts of the pictures?
Answers: 3
question
Computers and Technology, 24.06.2019 04:30
1. web and mobile applications allow users to be actively engaged in an online activity. a true b false 2. some examples of business applications purposes are to collaborate, share files, meet virtually in real-time, and accept payments. a true b false 3. an education application would most likely do which of the following? a allow users to watch popular movies and tv shows b connect users with social and business contacts c confirm users' travel plans d teach users a new language 4. a uniform resource locator (url) is how the internet knows where to take users when an address is typed into a browser. a true b false 5. deon is required to provide the citation information for his sources. what type of information should he collect from his sources? a author name, title, date of publication, date of access, url b connections to background information c interesting facts and statistics d notes on important information
Answers: 1
question
Computers and Technology, 24.06.2019 12:30
Why does the pc send out a broadcast arp prior
Answers: 1
You know the right answer?
Write the class RoadSegmet. The class inherits from Transportation Class. The Class have a vector ho...
Questions
question
Mathematics, 22.11.2020 22:40
question
Geography, 22.11.2020 22:40
Questions on the website: 13722367