consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
#include "Blinds.h"
Blinds::Blinds(std::string id, std::string name, bool shaded) : Device(id, name), shaded(shaded) {}
std::string Blinds::isShaded() const {
return (shaded) ? "open" : "closed";
}
std::string Blinds::toString() const {
return " id: " + id + " name: " + name + " is shaded: " + isShaded() + "\n";
}

View File

@@ -0,0 +1,19 @@
#ifndef NALOGA0502_BLINDS_H
#define NALOGA0502_BLINDS_H
#include "Device.h"
class Blinds : public Device{
private:
bool shaded;
public:
Blinds(std::string id, std::string name, bool shaded);
std::string isShaded() const;
std::string toString() const override;
};
#endif //NALOGA0502_BLINDS_H

View File

@@ -0,0 +1,9 @@
#include "Device.h"
Device::Device(std::string id, std::string name) : id(id), name(name) {}
std::string Device::toString() const {
return " id: " + id + " name: " + name + "\n";
}

View File

@@ -0,0 +1,16 @@
#ifndef NALOGA0502_DEVICE_H
#define NALOGA0502_DEVICE_H
#include <string>
class Device {
protected:
std::string id, name;
public:
Device(std::string id, std::string name);
virtual std::string toString() const;
};
#endif //NALOGA0502_DEVICE_H

View File

@@ -0,0 +1,11 @@
#include "GarageDoor.h"
GarageDoor::GarageDoor(std::string id, std::string name, bool open) :Device(id, name), open(open){}
std::string GarageDoor::isOpen() const {
return (open) ? "open" : "closed";
}
std::string GarageDoor::toString() const {
return " id: " + id + " name: " + name + " is open: " + isOpen() + "\n";
}

View File

@@ -0,0 +1,19 @@
#ifndef NALOGA0502_GARAGEDOOR_H
#define NALOGA0502_GARAGEDOOR_H
#include "Device.h"
class GarageDoor: public Device{
private:
bool open;
public:
GarageDoor(std::string id, std::string name, bool open);
std::string isOpen() const;
std::string toString() const override;
};
#endif //NALOGA0502_GARAGEDOOR_H

View File

@@ -0,0 +1,11 @@
#include "Light.h"
Light::Light(std::string id, std::string name, bool turnedOn) : Device(id, name), turnedOn(turnedOn) {}
std::string Light::isOn() const {
return (turnedOn) ? "on" : "off";
}
std::string Light::toString() const {
return " id: " + id + " name: " + name + " turnedOn: " + isOn() + "\n";
}

View File

@@ -0,0 +1,19 @@
#ifndef NALOGA0502_LIGHT_H
#define NALOGA0502_LIGHT_H
#include "Device.h"
class Light: public Device{
private:
bool turnedOn;
public:
Light(std::string id, std::string name, bool turnedOn);
std::string isOn() const;
std::string toString() const override;
};
#endif //NALOGA0502_LIGHT_H

View File

@@ -0,0 +1,30 @@
Naslednja naloga predstavlja opis pametnega doma:
Napišite razred Device, ki ima:
instančni spremenljivki id in name (oboje tipa string),
konstruktor z 2 parametroma in
metodo toString.
Napišite razred Light, ki deduje iz razreda Device. Nov razred naj ima:
dodatno instančno spremenljivko turnedOn (bool),
konstruktor s 3 parametri in
metodo toString.
Napišite razred SmartHome, ki ima:
instančni spremenljivki name (string) in devices (vector<Device*>),
konstruktor z 1 parametrom (samo name),
destruktor, ki izbriše objekte iz devices (gre za kompozicijo),
metodo addDevice in
metodo toString.
Sami dodajte še 2 smiselna razreda, ki bosta dedovala iz razreda Device.
V glavnem programu zapišite oz. sestavite program, ki bo predstavljal eno pametno hišo, ki ima znotraj devices nekaj primerkov naprav (Device, Light ...).
Za nalogo narišite diagram UML. Lahko na list papirja, vendar ga je treba slikati ali skenirati in tudi oddati na eštudij. Lahko pa ustvarite uml diagram s pomočjo https://app.diagrams.net/ ali s podobno aplikacijo.
Napotki pri reševanju naloge:
Pazite na uporabo protected, virtual in override.
Pri reševanju naloge upoštevajte vso dosedaj pridobljeno znanje (uporaba inicializacijskega seznama, konstantne metode, zapišite si metode get/set tam, kjer jih potrebujete itd.).

View File

@@ -0,0 +1,20 @@
#include "SmartHome.h"
SmartHome::SmartHome(std::string name) : name(name){}
SmartHome::~SmartHome(){
for (Device* device: devices) {
delete device;
}
}
std::string SmartHome::toString() const {
std::string str;
str = "House name: " + name + "\n";
for (auto device : devices) str += device->toString();
return str;
}
void SmartHome::addDevice(Device *device) {
devices.push_back(device);
}

View File

@@ -0,0 +1,26 @@
#ifndef NALOGA0502_SMARTHOME_H
#define NALOGA0502_SMARTHOME_H
#include <vector>
#include "Device.h"
#include "Light.h"
#include "Blinds.h"
#include "GarageDoor.h"
#include "WateringSistem.h"
class SmartHome {
private:
std::string name;
std::vector<Device*> devices;
public:
explicit SmartHome(std::string name);
~SmartHome();
std::string toString() const;
void addDevice(Device *device);
};
#endif //NALOGA0502_SMARTHOME_H

View File

@@ -0,0 +1,7 @@
#include "WateringSistem.h"
WateringSistem::WateringSistem(std::string id, std::string name, int startHour, int endHour) : Device(id,name), startHour(startHour), endHour(endHour) {}
std::string WateringSistem::toString() const {
return " id: " + id + " name: " + name + " start hour: " + std::to_string(startHour) + " end hour: " + std::to_string(endHour) + "\n";
}

View File

@@ -0,0 +1,16 @@
#ifndef NALOGA0502_WATERINGSISTEM_H
#define NALOGA0502_WATERINGSISTEM_H
#include "Device.h"
class WateringSistem : public Device {
private:
int startHour, endHour;
public:
WateringSistem(std::string id, std::string name, int startHour, int endHour);
std::string toString() const override;
};
#endif //NALOGA0502_WATERINGSISTEM_H

View File

@@ -0,0 +1,19 @@
#include <iostream>
#include "SmartHome.h"
int main() {
SmartHome* nik = new SmartHome("SH");
Device* lig = new Light("ha","ja", true);
Device* device = new Device("haja", "lada");
Device* blind = new Blinds("bli", "ka", true);
Device* garage = new GarageDoor("dor", "dore", false);
Device* water = new WateringSistem("water", "sistem", 15698,12345);
nik->addDevice(lig);
nik->addDevice(device);
nik->addDevice(blind);
nik->addDevice(garage);
nik->addDevice(water);
std::cout << nik->toString();
delete nik;
return 0;
}

View File

@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2022-03-28T12:31:55.235Z" agent="5.0 (Windows)" etag="QqLV9jsSKciBJbAK_OLZ" version="17.2.4" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">7VpZb+M2EP41BtICNnT6ePSRo9mkza7TJtmXgLZoWY0kein6ykN/eymROknfVhx3awSIOOIhzjfzzQylit71Ft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