|Will have you write a program that defines a class that does not do DMA.|
The class won’t be a template class (it will just be an ordinary class)
The class won’t use inheritance
The class won’t use static functions (just non-static ones)
The class won’t use static data members (just non-static ones)
The class will have a ctor, and possibly multiple ctors.
The ctors will complain and die if passed bogus args.
The class won’t need a dtor (destructor), since there will be no DMA
The class won’t have overloaded operators
The class will have accessor methods
The class will have mutator methods
The mutator methods will complain and die if passed bogus args
The class will have a method that inputs info into the class object.
The input method will complain and die if the input is bogus
The class will have an output method that outputs the info in the class object.
I’ll have you write code in the main program that creates an object of this non-DMA class, and passes it to a non-class function that does some stuff with it.
Here’s an example of such a non-DMA class:
Write a class Weather. A class object of type Weather represents the temperature, pressure, and humidity of a weather measurement. All 3 of these data generally have fractional parts, so let’s make them doubles. temperature must be in the range [-100, 100], or it’s bogus; pressure must be in the range [5e4, 2e5], or it’s bogus; humidity must be in the range [0, 100], or it’s bogus.
// ctor: If any of the args are outside the legal range, complain and die. Otherwise, construct an object
// that represents these values.
Weather( double temperature, double pressure, double humidity );
double getTemperature() const;
double getPressure() const;
double getHumidity() const;
// mutators: mutators should complain and die if passed a bogus arg
void setTemperature( double temperature );
void setPressure( double pressure );
void getHumidity( double humidity );
// input method inputs values of temperature, pressure, and humidity into Weather object.
// input should complain and die if input fails, or if any of the values is bogus.
// I don’t care about prompts.
// output method outputs the values of temperature, pressure, and humidity.
// I don’t care about explanatory text
void output() const;
// private stuff would go here
}; // class Weather
// temperature increase is not a class function, it’s just an ordinary function that has a Weather arg and
// that returns a Weather object.
// Its job is to create and return a Weather object that’s the same as the Weather arg w, except that the
// weather object that’s returned is degreesIncrease degrees hotter than w. If degreesIncrease is
// negative, then the object returned is colder than w.
// If the new temperature is bogus (too hot or too cold), the program should complain and die
// instead of returning from temperatureIncrease.
Weather temperatureIncrease( const Weather & w, double degreesIncrease );
// main’s job is to create a Weather object, input (with the input method) values into it, pass it to
// temperatureIncrease to get a Weather object that’s 10 degrees warmer, and output (with the
// output method) that warmer object.