Hi guys, so I have this homework with a sensor that measure temp, humidity and pressure. We had been given this UML https://imgur.com/a/UiDV7gq . We have to implement theese classes: Temperature, Humidity, Pressure generateTemperature() / generateHumidity() / generatePressure() / readSensor() / IRoom for Living, Bedroom, Bathroom and Kitchen with the metods createRoom() / readRoom() / updateRoom() / deleteRoom() / collectRoomData() / viewRoomData().
Have no idea how to start, i didn't find anything useful yet, hope u can help me.
The UML diagram is unnecessarily complicated. A House/Room/Sensor combination is all that's required along with a few separate interface components and <vector> data storage.
Aside from that you need to have a clear understanding of what the system is supposed to do - I am assuming (f-last words) that it generates data input/manages it - with flexibility for adding componets to rooms in different houses.
Of course it might be a real estate or franchised sensor hardware shop - who knows?
> #ifndef Temperature_H
> #define Temperatur_H
Spelling is important.
Do this once (and only once) at the start of main()
Calling srand() multiple times in the same second makes the result of rand() decidedly non-random.
Your classes seem fine from an overview.
But where do the files come into it in the room?
I would have guessed that readRoom would involve some use of readSensor for each of the sensors stored in the vector.
Thank you for responses, so the requirment was(translated): Write a C ++ application that implements the case monitoring system according to the UML diagram and specifications. To test the program, imagine a home that has at least one room in each of the 4 types, and several sensors are installed in each room, but at least one of the 3 types.
And gave us 3 files, one with UML and instructions, one for pressure and one for humidity and temperature(we have been given BMP280 and AM2320 I see that they are popular).
I will attach if needed for more info. And for the data it says like this:
"The generateTemperature () / generateHumidity () / generatePressure () methods generate a random number in the range [min, max] given by the sensor-specific datasheet: temperature (˚C), humidity (%), and pressure (hPa) ;"
It sounds strange that you have specific components and yet so far no mention of a microcontroller or other hardware. The point being, except for data ranges, what's the intent behind supplying the datasheets?
The UML diagram is pretty and all, but what are the various methods supposed to actually do? For example, what does LivingRoom::createRoom() do? I assume readRoom() reads info about the room, but from where? Is the deleteRoom() method really just the destructor for the class? It's hard to know exactly what these classes should do without the details.
Let the interrogation continue - so far we know it's some sort of a system that's supposed to do something. However, we know a little bit - and enough to allow @OP to proceed :)
So, in the interests of helping with the first steps, @OP needs to:
1. fix up the typos and the srand stuff etc @salem mentions above, then
2. start writing a simple main() and create a room and a sensor. Just one of each putting the sensor in the room vector.