Question
Programming in C++ USING DEQUE A company that provides a special service for wind surfers installs wind gauges at popular windsurfing locations. Each gauge reports
Programming in C++
USING DEQUE
A company that provides a special service for wind surfers installs wind gauges at popular windsurfing locations. Each gauge reports the current wind speed to a central computer every 5 minutes. When a user connects to the service she or he is able to retrieve recent high, low, and average wind speeds for her or his selected location. The central computer creates a WindGauge object for each gauge. The WindGauge class interface looks as follows:
class WindGauge {
public:
WindGauge(int period = 12);
void currentWindSpeed(int speed);
int highest() const;
int lowest() const;
int average() const;
private:
// add properties and/or method(s) here
};
The constructor argument specifies how much history is retained by the object (default 12 periods which is 1 hour). When currentWindSpeed() is called, the current wind speed is added to the history. If the history is then longer than the specified period, the oldest wind speed is discarded. The other three functions return the highest, lowest, and average wind speeds reported during the history period.
Implement the WindGauge class as specified above. Add properties to the class and write a dump function that prints out the lowest, highest, and average wind speed for a WindGauges data. Write a test program that does the following:
1. Create a WindGauge object
2. Add five wind speeds: 15, 16, 12, 15, and 15, and then dump the gauge.
3. Add ten more measurements: 16, 17, 16, 16, 20, 17, 16, 15, 16, and 20 (bringing the total to over 12) and dump the numbers again.
Separate your code into three files: WindGauge.h (class definition), WindGauge.cpp (implementation of methods) and testWindGauge.cpp (test program). DEQUE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started