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,7 @@
#include "Artist.h"
Artist::Artist(std::string name, std::string biography, unsigned int day, unsigned int month, unsigned int year) : name(name), biography(biography), dateOfBirth(day, month, year){}
std::string Artist::toString() const {
return name + ", " + biography + ", " + dateOfBirth.toString();
}

View File

@@ -0,0 +1,20 @@
#ifndef NALOGA0201_ARTIST_H
#define NALOGA0201_ARTIST_H
#include "Date.h"
class Artist {
private:
std::string name, biography;
Date dateOfBirth;
public:
Artist() = default;
Artist(std::string name, std::string biography, unsigned int day, unsigned int month, unsigned int year);
~Artist() = default;
std::string toString() const;
};
#endif //NALOGA0201_ARTIST_H

View File

@@ -0,0 +1,13 @@
#include "Artwork.h"
Artwork::Artwork(std::string title, std::string description, int price, int year, Artist *artist, double width, double height, double depth) :
title(title), description(description), price(price), year(year), artist(artist), dimension(width, height, depth){}
std::string Artwork::toString() const {
return "Title: " + title +
"\nDescription: " + description +
"\nPrice: " + std::to_string(price) +
" EUR\nYear: " + std::to_string(year) +
"\nArtist: " + artist->toString() +
"\nDimension: " + dimension.toString() + "\n\n";
}

View File

@@ -0,0 +1,23 @@
#ifndef NALOGA0201_ARTWORK_H
#define NALOGA0201_ARTWORK_H
#include "Artist.h"
#include "Dimension.h"
class Artwork {
protected:
std::string title, description;
int price, year;
Artist *artist;
Dimension dimension;
public:
Artwork() = default;
Artwork(std::string title, std::string description, int price, int year, Artist *artist, double width, double height, double depth);
~Artwork() = default;
virtual std::string toString() const;
};
#endif //NALOGA0201_ARTWORK_H

View File

@@ -0,0 +1,7 @@
#include "Date.h"
Date::Date(unsigned int day, unsigned int month, unsigned int year) : day(day), month(month), year(year) {}
std::string Date::toString() const {
return std::to_string(day) + ", " + std::to_string(month) + ", " + std::to_string(year);
}

View File

@@ -0,0 +1,19 @@
#ifndef NALOGA0201_DATE_H
#define NALOGA0201_DATE_H
#include <string>
class Date {
private:
unsigned int day, month, year;
public:
Date() = default;
Date(unsigned int day, unsigned int month, unsigned int year);
~Date() = default;
std::string toString() const;
};
#endif //NALOGA0201_DATE_H

View File

@@ -0,0 +1,9 @@
#include "Dimension.h"
Dimension::Dimension(double width, double height, double depth) : width(width), height(height), depth(depth) {
}
std::string Dimension::toString() const {
return std::to_string(width) + " " + std::to_string(height) + " " + std::to_string(depth);
}

View File

@@ -0,0 +1,18 @@
#ifndef NALOGA0201_DIMENSION_H
#define NALOGA0201_DIMENSION_H
#include <string>
class Dimension {
private:
double width, height, depth;
public:
Dimension() = default;
Dimension(double width, double height, double depth);
~Dimension() = default;
std::string toString() const;
};
#endif //NALOGA0201_DIMENSION_H

View File

@@ -0,0 +1,20 @@
#include "Gallery.h"
#include <iostream>
Gallery::Gallery(std::string name) : name(name) {
}
void Gallery::addArtwork(Artwork *artwork) {
artworks.push_back(artwork);
}
void Gallery::printArtworks() const {
for (auto &artwork: artworks)
std::cout << artwork->toString() << std::endl;
}
std::string Gallery::toString() const {
std::string ret;
for (auto &artwork: artworks) ret += artwork->toString() + "\n\n";
return ret;
}

View File

@@ -0,0 +1,28 @@
#ifndef NALOGA0201_GALLERY_H
#define NALOGA0201_GALLERY_H
#include "Artwork.h"
#include "Painting.h"
#include "Literature.h"
#include <vector>
class Gallery {
private:
std::string name;
std::vector<Artwork *> artworks;
public:
Gallery() = default;
explicit Gallery(std::string name);
~Gallery() = default;
void addArtwork(Artwork *artwork);
void printArtworks() const;
std::string toString() const;
};
#endif //NALOGA0201_GALLERY_H

View File

@@ -0,0 +1,47 @@
#include "Literature.h"
Literature::Literature(std::string title, std::string description, int price, int year, Artist *artist, double width, double height, double depth, LiteratureType material) :
Artwork(title, description, price, year, artist, width, height, depth), material(material) {}
std::string Literature::getMaterial() const{
switch (material) {
case LiteratureType::Drama:
return "Drama";
break;
case LiteratureType::Biography:
return "Biography";
break;
case LiteratureType::Poetry:
return "Poetry";
break;
case LiteratureType::Prose:
return "Prose";
break;
case LiteratureType::ScienceFiction:
return "Science fiction";
break;
default:
return "?";
}
}
std::string Literature::toString() const {
return "Title: " + title +
"\nDescription: " + description +
"\nPrice: " + std::to_string(price) +
" EUR\nYear: " + std::to_string(year) +
"\nArtist: " + artist->toString() +
"\nDimension: " + dimension.toString() +
"\nPainting technique: " + getMaterial() + "\n\n";
}
void Literature::print() const {
std::cout <<
"Title: " << title <<
"\nDescription: " << description <<
"\nPrice: " << std::to_string(price) <<
" EUR\nYear: " << std::to_string(year) <<
"\nArtist: " << artist->toString() <<
"\nDimension: " << dimension.toString() <<
"\nLiterature type: " << getMaterial() << "\n\n";
}

View File

@@ -0,0 +1,22 @@
#ifndef NALOGA0201_LITERATURE_H
#define NALOGA0201_LITERATURE_H
#include "Artwork.h"
#include <iostream>
enum class LiteratureType {
Drama, Biography, Poetry, Prose, ScienceFiction,
};
class Literature: public Artwork {
private:
LiteratureType material;
public:
Literature(std::string title, std::string description, int price, int year, Artist *artist, double width, double height, double depth, LiteratureType material);
std::string getMaterial() const;
std::string toString() const override;
void print() const;
};
#endif //NALOGA0201_LITERATURE_H

View File

@@ -0,0 +1,31 @@
#include "Painting.h"
Painting::Painting(std::string title, std::string description, int price, int year, Artist *artist, double width, double height, double depth, PaintingTechnique technique) :
Artwork(title, description, price, year, artist, width, height, depth), technique(technique) {}
std::string Painting::getTechnique() const{
switch (technique) {
case PaintingTechnique::Oil:
return "Oil";
break;
case PaintingTechnique::Acrylic:
return "Acrylic";
break;
case PaintingTechnique::Graphite:
return "Graphite";
break;
default:
return "?";
}
}
std::string Painting::toString() const {
return "Title: " + title +
"\nDescription: " + description +
"\nPrice: " + std::to_string(price) +
" EUR\nYear: " + std::to_string(year) +
"\nArtist: " + artist->toString() +
"\nDimension: " + dimension.toString() +
"\nPainting technique: " + getTechnique() + "\n\n";
}

View File

@@ -0,0 +1,28 @@
#ifndef NALOGA0201_PAINTING_H
#define NALOGA0201_PAINTING_H
#include "Artwork.h"
enum class PaintingTechnique {
Oil,
Acrylic,
Graphite
};
class Painting : public Artwork {
private:
PaintingTechnique technique;
public:
Painting() = default;
Painting(std::string title, std::string description, int price, int year, Artist *artist, double width, double height, double depth, PaintingTechnique technique);
~Painting() = default;
std::string getTechnique() const;
std::string toString() const override;
};
#endif //NALOGA0201_PAINTING_H

View File

@@ -0,0 +1,15 @@
Vzemite nalogo 4.1.
Dodajte razed Painting, ki deduje iz razreda Artwork. Nov razred naj ima:
dodatno instančno spremenljivko technique tipa PaintingTechnique - dodajte enum class(https://en.cppreference.com/w/cpp/language/enum) PaintingTechnique, ki ima vrednosti Oil, Acrylic in Graphite. enum class PaintingTechnique naj bo napisan nad deklaracijo razreda Painting.
konstruktor s 6 parametri,
metodo toString in
metodo print.
V glavnem programu zapišite oz. sestavite program, ki bo predstavljal eno galerijo, ki ima znotraj artworks:
2 primerka tipa Artwork in
2 primerka tipa Painting.
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.). uml_diagram_task0501.png

View File

@@ -0,0 +1,36 @@
#include <iostream>
#include "Gallery.h"
int main() {
Gallery slo("galer");
Artist artist1("Leonardo da Vinci", "biografi", 15, 4, 1452);
Artwork art1("Mona Lisa", "desc", 100, 1797, &artist1, 32,56,94);
slo.addArtwork(&art1);
Artist artist2 = {"Vincent van Goth", "bio", 30, 3, 1853};
Artwork art2 = {"The starry Night", "desc", 256, 1889, &artist2, 56,86,15};
slo.addArtwork(&art2);
Artist artist3 = {"Jahannes Vermeer", "biog", 1, 10, 1632};
Artwork art3 = {"Girl with a Pearl Erring", "desc", 568, 1665, &artist3, 59,56,1};
slo.addArtwork(&art3);
Artist artist4 = {"Gustav Klimt", "biog", 14, 7, 1862};
Artwork art4 = {"The kiss", "desc", 465, 1907, &artist4, 47,56,2};
slo.addArtwork(&art4);
Artist artist5 = {"Sandro Botticelli", "biog", 17, 5, 1510};
Artwork art5 = {"The birth of Venus", "desc", 573, 1458, &artist5,56,89,3.56};
slo.addArtwork(&art5);
Artwork* painting1 = new Painting {"itoao","desc",1598,789, &artist3,43,4,7,PaintingTechnique::Oil};
slo.addArtwork(painting1);
Artwork* Liter = new Literature("liter", "description", 597, 1590, &artist2, 56,86,15,LiteratureType::Biography);
slo.addArtwork(Liter);
slo.printArtworks();
//std::cout << slo.toString();
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB