Reputation: 13
I think that I must be missing something on this assignment for my c++ class but i am not getting something that it is asking us to do.
The question: Create a Road class. The class should have functions for setting the width of the road in feet and the length of the road in miles. It should also have functions for obtaining the width of the road and the the length of the road. Remember that the class functions should not interact with the user of the program, either by providing the output or by getting input. Create a function called asphalt the will accept a road thickness as an input parameter; then on the basis of the thickness, it will compute and return the number of cubic feet of asphalt needed to pave the road (1 mile = 5280 feet). Test each function of the class throughly with a driver.
My problem: What I do not understand is how we are supposed to know what the formula to return to return the amount of cubic feet of asphalt needed is and what unit "thickness would even be", am I missing something here. Any help would be great.
My current code:
#include<iostream>
using namespace std;
class Road
{
private:
int length_miles;
int width_feet;
public:
void set_length(int l)
{
length_miles = l;
}
void set_width(int w)
{
width_feet = w;
}
int get_length()
{
return length_miles;
}
int get_width()
{
return width_feet;
};
int asphalt(int thickness)
{
return 1+1; //placeholder forumala
}
};
int main()
{
Road MainRoad;
int length;
int width;
int thickness;
cout << "Please enter the length of the road in miles" << endl;
cin >> length;
MainRoad.set_length(length);
cout << "Please enter the width of the road in feet" << endl;
cin >> width;
MainRoad.set_width(width);
cout << "Please enter the thickness of the road in BLANK" << endl;
cin >> thickness;
cout << "The amount of asphalt needed for the road is " << MainRoad.asphalt(thickness);
}
Upvotes: 0
Views: 185
Reputation: 2325
I would agree with @Beta that in the absence of a mandatory unit for thickness you are free to pick your own.
But since the method prototype uses int as the C++ data type for thickness, and asphalt thickness in my imagination is typically less that 1 foot, you should use a more appropriate unit than feet. Like inches or centimeters. Since inches fit better with the other imperial units used in the class, I would use inches.
Upvotes: 1