consolidate all repos to one for archive
This commit is contained in:
7
semester_2/programiranje_2/naloga0501/Artist.cpp
Normal file
7
semester_2/programiranje_2/naloga0501/Artist.cpp
Normal 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();
|
||||
}
|
20
semester_2/programiranje_2/naloga0501/Artist.h
Normal file
20
semester_2/programiranje_2/naloga0501/Artist.h
Normal 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
|
13
semester_2/programiranje_2/naloga0501/Artwork.cpp
Normal file
13
semester_2/programiranje_2/naloga0501/Artwork.cpp
Normal 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";
|
||||
}
|
23
semester_2/programiranje_2/naloga0501/Artwork.h
Normal file
23
semester_2/programiranje_2/naloga0501/Artwork.h
Normal 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
|
7
semester_2/programiranje_2/naloga0501/Date.cpp
Normal file
7
semester_2/programiranje_2/naloga0501/Date.cpp
Normal 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);
|
||||
}
|
19
semester_2/programiranje_2/naloga0501/Date.h
Normal file
19
semester_2/programiranje_2/naloga0501/Date.h
Normal 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
|
9
semester_2/programiranje_2/naloga0501/Dimension.cpp
Normal file
9
semester_2/programiranje_2/naloga0501/Dimension.cpp
Normal 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);
|
||||
}
|
18
semester_2/programiranje_2/naloga0501/Dimension.h
Normal file
18
semester_2/programiranje_2/naloga0501/Dimension.h
Normal 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
|
20
semester_2/programiranje_2/naloga0501/Gallery.cpp
Normal file
20
semester_2/programiranje_2/naloga0501/Gallery.cpp
Normal 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;
|
||||
}
|
28
semester_2/programiranje_2/naloga0501/Gallery.h
Normal file
28
semester_2/programiranje_2/naloga0501/Gallery.h
Normal 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
|
||||
|
47
semester_2/programiranje_2/naloga0501/Literature.cpp
Normal file
47
semester_2/programiranje_2/naloga0501/Literature.cpp
Normal 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";
|
||||
}
|
22
semester_2/programiranje_2/naloga0501/Literature.h
Normal file
22
semester_2/programiranje_2/naloga0501/Literature.h
Normal 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
|
31
semester_2/programiranje_2/naloga0501/Painting.cpp
Normal file
31
semester_2/programiranje_2/naloga0501/Painting.cpp
Normal 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";
|
||||
}
|
||||
|
28
semester_2/programiranje_2/naloga0501/Painting.h
Normal file
28
semester_2/programiranje_2/naloga0501/Painting.h
Normal 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
|
15
semester_2/programiranje_2/naloga0501/README.md
Normal file
15
semester_2/programiranje_2/naloga0501/README.md
Normal 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
|
36
semester_2/programiranje_2/naloga0501/naloga0501.cpp
Normal file
36
semester_2/programiranje_2/naloga0501/naloga0501.cpp
Normal 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;
|
||||
}
|
BIN
semester_2/programiranje_2/naloga0501/uml_diagram_task0501.png
Normal file
BIN
semester_2/programiranje_2/naloga0501/uml_diagram_task0501.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
Reference in New Issue
Block a user