program using classes

so i've been working on this program for a couple hours now and i am completely stuck. i've contacted my professor, but he only repeats himself.

here is what he wants:
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.

class Weather{
private:

// 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 );

// accessors
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.
void input();

// output method outputs the values of temperature, pressure, and humidity.
// I don’t care about explanatory text
void output() const;

private:
// 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.


and here is my code currently:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <iostream>
#include <string>

using namespace std;

class Weather
{

public:
	Weather (double temperature, double pressure, double humidity);
	//  accessors
	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 setHumidity( double humidity );

	void input();
	void output() const;

private:
	double temperature;
	double pressure;
	double humidity;
	double * ptr;
	
}; // class weather

Weather temperatureIncrease (const Weather & w, double degreesIncrease);
bool die (const string & msg);

int main()
{
	Weather w(1, 2, 3);
	w.input();
	Weather x(w);
	x.output();

	


	
	system("Pause");
	return (0);
	
} //main

Weather::Weather (double temperature, double pressure, double humidity)
{
	temperature = temperature;
	pressure = pressure;
	humidity = humidity; 

}

double Weather::getTemperature() const
{
	return temperature;

}

double Weather::getPressure() const
{
	return pressure;

}

double Weather::getHumidity() const
{
	return humidity;

}

void Weather::setTemperature( double temperature )
{
	if (temperature < -100 || temperature > 100)
		die ("Weather:setTemperature: Index out of range");

}
	
void Weather::setPressure( double pressure)
{
	if (pressure < 5e4 || pressure > 2e5)
		die ("Weather:setPressure: Index out of range");

}

void Weather::setHumidity( double humidity )
{
	if (humidity < -0 || humidity > 100)
		die ("Weather:setHumidity: Index out of range");
}

void Weather::input()
{
	cout << "What is the temperature? ";
	cin >> temperature;

	cout << "What is the pressure? ";
	cin >> pressure;

	cout << "What is the humidity? ";
	cin >> humidity;
	cout << endl;

}

void Weather::output() const
{
	cout << "New Temperature: " << temperature << endl;
	cout << "Pressure: " << pressure << endl;
	cout << "Humidity: " << humidity << endl;
	cout << endl;
	
}

Weather temperatureIncrease (Weather & w, double degreesIncrease)
{
	
	w.setTemperature (w.getTemperature() + degreesIncrease);
	return w;

}


bool die (const string & msg)
{
    cerr << endl << "Fatal error: " << msg << endl;
	system("Pause");
    exit (EXIT_FAILURE);
} //die 


it runs and executes but i can't seem to get the temperature to increment by 10 degrees. can someone please guide me in the correct direction. thanks in advance!
Topic archived. No new replies allowed.