Computers and Technology

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;
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:50, akornegay2
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: a. double the number. b. reverse the digits of the number. c. raise the number to the power of 2, 3, or 4. d. sum the digits of the number. e. if the number is a two-digit number, then raise the first digit to the power of the second digit. f. if the number is a three-digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit. after performing an operation if the number is less than 10, add 10 to the number. also, after each operation determine if the number is prime. each successive operation should be performed on the number generated by the last operation. your program should not contain any global variables and each of these operations must be implemented by a separate function. also, your program should be menu driven. 7. (fraction calculator) write a program that
Answers: 1
image
Computers and Technology, 25.06.2019 05:40, Juancr4539
How to make a negative number positive in excel
Answers: 3
image
Computers and Technology, 25.06.2019 08:00, lizzyhearts
Which of the following statements is true of an intranet? it is a network where a computer is connected to the internet and acts as a gateway for other devices. it is a widely available public network of interconnected computer networks. it is a network that covers a wide area with the of rented telecommunication lines. it is a network within an organization that uses internet protocols and technologies.
Answers: 3
image
Computers and Technology, 25.06.2019 15:10, seoulux
Write a program to compute the ideal weight for both males and females in java. according to one study, the ideal weight for a female is 100 pounds plus 5 pounds for each inch in height over 5 feet. for example, the ideal weight for a female who is 5'3" would be 100 + 3*5 = 115 pounds. for a male, the ideal weight is 106 pounds plus 6 pounds for each inch in height over 5 feet. for example, the ideal weight for a male who is 5'3" would be 106 + 3*6 = 124 pounds. your program should ask the user to enter his/her height in feet and inches (both as integers—so a person 5'3" would enter the 5 and the 3). it should then compute and print both the ideal weight for a female and the ideal weight for a male. the general outline of your main function would be as follows: (1) declare your variables (think about what variables you need—you need to input two pieces of information, then you need some variables for your calculations (see the following steps) (2) get the input (height in feet and inches) from the user (3) compute the total number of inches of height (convert feet and inches to total inches (note: 1 foot equal 12 inches and hence 5 feet equal 60 inches. (4) compute the ideal weight for a female and the ideal weight for a male (5) print the answers.
Answers: 2
Do you know the correct answer?
Write the class RoadSegmet. The class inherits from Transportation Class. The Class have a vector ho...

Questions in other subjects:

Konu
History, 29.04.2021 20:40
Konu
Spanish, 29.04.2021 20:40
Konu
Mathematics, 29.04.2021 20:40