{"id":25841990,"url":"https://github.com/courseworks/ap1399-2-hw2","last_synced_at":"2026-06-22T01:31:25.029Z","repository":{"id":119844417,"uuid":"347210287","full_name":"courseworks/ap1399-2-hw2","owner":"courseworks","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-12T22:11:03.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-04T02:33:21.849Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/courseworks.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-03-12T22:08:53.000Z","updated_at":"2021-03-12T22:11:05.000Z","dependencies_parsed_at":"2023-06-03T08:30:33.390Z","dependency_job_id":null,"html_url":"https://github.com/courseworks/ap1399-2-hw2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/courseworks/ap1399-2-hw2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/courseworks%2Fap1399-2-hw2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/courseworks%2Fap1399-2-hw2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/courseworks%2Fap1399-2-hw2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/courseworks%2Fap1399-2-hw2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/courseworks","download_url":"https://codeload.github.com/courseworks/ap1399-2-hw2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/courseworks%2Fap1399-2-hw2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34630770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-01T05:33:06.088Z","updated_at":"2026-06-22T01:31:24.998Z","avatar_url":"https://github.com/courseworks.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ccenter\u003e\n\u003ch1\u003e\nIn The Name Of ALLAH\n\u003c/h1\u003e\n\u003ch2\u003e\nAdvanced Programming - Homework 2\n\u003c/h2\u003e\n\u003ch2\u003e\nDr.Amir Jahanshahi\n\u003c/h2\u003e\n\u003ch3\u003e\nDeadline: Friday, 13 Farvardin - 23:00\n\u003c/center\u003e\n\n\u003cimg src=\"stuff/m1.jpg\" width=\"300\" /\u003e\n\n# Introduction\nIn this homework, you'll be implementing a **super!** smart room in C++. This room has a **DHT11** sensor to measure both temperature and humidity. Let's see.\n\n**Note**: You must not remove any keyword in variables and functions definitions, but you can add some keywords wherever necessary.\n\n# Room Class\nThis class represents our room. It has the following member functions and member variables.\n\n```c++\nclass Room{\nprivate:\n    size_t id;\n    double temperature{28};\n    double humidity{95};  //  Make this as last 2 digits of your student no\n    std::unique_ptr\u003cDHT11\u003e dht;\n\npublic:\n    Room(size_t id, double temperature, double humidity);\n    double getTemperature() const;\n    double getHumidity() const;\n    void changeTemperatureStdev(double stdev);\n    void changeHumidityStdev(double stdev);\n};\n```\n\nNames of variables and functions are clear about their application. You only need to know about the **DHT11** class now.\n\n#  DHT11 Class\nThis class represents the sensor. It has a pointer to the room to get the temperature and humidity. But, as every sensor has, this sensor has some measurement noise. So it gets measurements as a **Normal** random variable with the specified mean (from the room class) and specified standard deviation. Let's see contents of this class.\n\n```c++\nclass DHT11{\n    private:\n        double temp_stdev{1};\n        double hum_stdev{1};\n        Room* proom;\n\n    public:\n        DHT11(double temp_stdev, double hum_stdev);\n        DHT11(double temp_stdev, double hum_stdev, Room* proom);\n        \n        double getTemperature() const;\n        double getHumidity() const;\n};\n```\n\n**Question 1**: What would you do for your code to be able to run the next block successfully? Explain and do it!\n\n```c++\nconst Room r2(2, 35, 50);\nr2.changeHumidityStdev(83);\nstd::pair\u003cdouble, double\u003e p{r2.\ndht-\u003egetStdevs()};\nstd::cout\u003c\u003cp.second\u003c\u003cstd::endl;  //  Prints 83\n```\n\n**Question 2**: Can you call a ```std::unique_ptr``` variable in a function, by value? If yes, explain how, and if no, explain why!\n\n# main File\nYou must not alter the **main.cpp** file at all. Just write all your codes in the **room** and **dht11** header and cpp files. Good luck!\n\n\u003cimg src=\"stuff/m2.jpg\"\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcourseworks%2Fap1399-2-hw2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcourseworks%2Fap1399-2-hw2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcourseworks%2Fap1399-2-hw2/lists"}