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]
3 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]3 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
Potential Energy and Kinetic Energy both mean "energy in motion" True or False​
Irina18 [472]

Answer:

false

Explanation:

pretty sure energy in motion is only for kinetic energy

4 0
3 years ago
Read 2 more answers
What term describes the amount you must pay in order to be considered “up-to-date” with your credit card payments?
yuradex [85]

Answer:

Minimum payment.

Explanation:

A loan can be defined as an amount of money that is being borrowed from a lender and it is expected to be paid back at an agreed date with interest.

Generally, the financial institution such as a bank lending out the sum of money usually requires that borrower provides a collateral which would be taken over in the event that the borrower defaults (fails) in the repayment of the loan.

A credit score can be defined as a numerical expression between 300 - 850 that represents an individual's financial history and credit worthiness. Therefore, a credit score determines the ability of a borrower to obtain a loan from a lender.

This ultimately implies that, the higher your credit score, the higher and better it is to obtain a loan from a potential lender. A credit score ranging from 670 to 739 is considered to be a good credit score while a credit score of 740 to 799 is better and a credit score of 800 to 850 is considered to be excellent.

Additionally, credit card can be defined as a small rectangular-shaped plastic card issued by a financial institution to its customers, which typically allows them to purchase goods and services on credit based on the agreement that the amount would be paid later with an agreed upon interest rate.

Minimum payment is a term which describes the amount you must pay in order to be considered “up-to-date” with your credit card payments. A credit card holder that meets the minimum payment and has a good credit score is eligible for more credits and loans.

4 0
3 years ago
Anyone watch anime, i love stay kids and they sang the op for Tower of God XD
TEA [102]

Answer:

I do Stray kids and Tower Of God is good combo mannnn

6 0
3 years ago
Read 2 more answers
Which of the following is not a type of computer network?
vagabundo [1.1K]
B. Metropolitan area network
7 0
3 years ago
Which feature of the basic input/output system (bios)/unified extensible firmware interface (uefi) would you enable if you wante
Paraphin [41]

The answer should be secure boot

5 0
3 years ago
Other questions:
  • What is the Multiplier if the change in RGDP is $525,000,000 and initial spending is $100,000?
    12·1 answer
  • A way to have cells in your spreadsheet change formats based on the value of the cells is called ________.
    8·1 answer
  • Crashing almost always accelerates the schedule while increasing project risk, whereas fast tracking almost always accelerates t
    10·1 answer
  • 18) choose which article title would most likely be described by the database subject headings victims of famine, ireland, histo
    14·1 answer
  • Which key you should you press to leave the cell as it orginally was
    14·2 answers
  • ____________ facilitates the processes that help an organization function by applying information and communication technologies
    5·1 answer
  • Katarina is deciding whether to buy a desktop or a laptop computer. What will most likely help Katarina make her decision?
    10·2 answers
  • How can you tell that a spreadsheet was saved as a 2007 Excel file?
    7·1 answer
  • Cisco Next Generation Intrusion Prevention System (NGIPS) devices include global correlation capabilities that utilize real-worl
    9·1 answer
  • Explain the emerging trends in microcomputer technology in relation to size​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!