1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
blondinia [14]
2 years ago
14

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::TransportationLink(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(double distance) {
_distance = distance;
}
Computers and Technology
1 answer:
OLEGan [10]2 years ago
5 0

Answer:

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<double> 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 <string>

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;

};

You might be interested in
Technician A says that high pressure in recycled refrigerant is only caused by air contamination. Technician B says that recycle
hjlf

Answer:

a. A only

Explanation:

When air, is in excess of allowable amounts, it  can cause the system to operate at pressures that are higher than normal. This means that the recycled refrigerant is operating at high pressure. Thus Technician A is correct.

However, Technician B is incorrect because unlike reclaimed refrigerants where the process strip the refrigerant of impurities making it to meet the standards of a new refrigerant, the recycled refrigerant is not as pure as it's contaminants are only reduced.

Therefore, only technician A is correct.

6 0
3 years ago
A(n) _____ is created using the select and option elements that present users with a group of predefined possible values for the
aniked [119]

Answer:

c. selection list.

Explanation:

A selection list is created using the select and option elements that present users with a group of predefined possible values for the data field.

In Computer programming, the selection list is used to avail the end users with the ability to engage in an operation such as a predefined possible values for the data field.

7 0
2 years ago
Identify two entities and 2 of their attributes from the given scenario.
polet [3.4K]

Bookstore and BookSearch are the two entities for the given scenario.

Explanation:

  • For the given Book.com virtual store, there can be two entities like Bookstore and BookSearch.
  • Bookstore can have all the details of the books in the virtual store. hence the attributes can be
  • Bookstore attributes: bookname, Authorname, Publisher, Publishedyear, Agegroup, category.
  • BookSearch entity can be used to search the books in the virtual store.
  • Booksearch attributes: bookname, category, bookid, authorname.
8 0
3 years ago
Suppose we want an error correcting code that will allow all single-bit errors to be corrected for memory words of length 15. 1.
alexira [117]

Answer:

15

Explanation:

01234567891011121314

5 0
2 years ago
If you are feeling sick and you want to drive somewhere, you should
Ganezh [65]

Answer

Ask someone to drive you.

Explanation

When feeling ill, or even taking medication before driving Is dangerous for the driver and other road users  because it slows reactions and the ability to make rapid corrective actions while driving. Driving while sick  can also have the same effects on a driver as if they were drinking.

5 0
3 years ago
Read 2 more answers
Other questions:
  • What type of document would you use the landscape page orientation
    7·1 answer
  • You should use the longest possible shutter speed for all firework photographs.
    8·2 answers
  • How do you convert a decimal to binary?
    9·2 answers
  • Which of these expressions evaluates to 4.0?
    12·2 answers
  • True or false? if the copyright date on the homepage is more than 1 year old, the website should always be considered unmaintain
    5·1 answer
  • Which of the following is the component of the processor that directs and coordinates most of the operations in the computer?A.
    12·1 answer
  • You are given an array of integers, each with an unknown number of digits. You are also told the total number of digits of all t
    7·1 answer
  • Before creating a brief to design a product, what is needed
    8·1 answer
  • One key criterion for selecting social networks is the number of daily visitors to the website. when comparing linkedin traffic
    7·1 answer
  • Which of the following terms means the computer operating system automatically detects and installs the proper driver for a new
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!