// This is the HEADER FILE templist.h. This is the INTERFACE for the class // TemperatureList. Values of this type are lists of Fahrenheit temperatures. #ifndef TEMPLIST_H #define TEMPLIST_H #include <iostream> const long MAX_LIST_SIZE = 50; class TemperatureList { double list[MAX_LIST_SIZE]; // of temperatures in Fahrenheit long size; // number of array positions filled public: // Initializes the object to an empty list. TemperatureList(void); // Precondition: The list is not full. // Postcondition: The temperature has been added to the END of the list, // if there was room. void add_temperature(double temperature); // Returns true if the list is full, false otherwise. bool full(void) const; // Returns the number of temperatures in the list. long get_size(void) const; // Precondition: 0 <= position < get_size() // Returns the temperature that was added in position // specified. The first temperature that was added is // in position 0. double get_temperature(long position) const; // Precondition: If outs is a file output stream, then outs has // already been connected to a file. // Postcondition: Temperatures are output one per line on the stream. void output(std::ostream & outs) const; }; #endif
Note: This project is adapted from ones given in textbooks by Walter Savitch.