consolidate all repos to one for archive
This commit is contained in:
7
semester_2/programiranje_2/naloga0401/Artist.cpp
Normal file
7
semester_2/programiranje_2/naloga0401/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/naloga0401/Artist.h
Normal file
20
semester_2/programiranje_2/naloga0401/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/naloga0401/Artwork.cpp
Normal file
13
semester_2/programiranje_2/naloga0401/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/naloga0401/Artwork.h
Normal file
23
semester_2/programiranje_2/naloga0401/Artwork.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef NALOGA0201_ARTWORK_H
|
||||
#define NALOGA0201_ARTWORK_H
|
||||
|
||||
#include "Artist.h"
|
||||
#include "Dimension.h"
|
||||
|
||||
class Artwork {
|
||||
private:
|
||||
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;
|
||||
|
||||
std::string toString() const;
|
||||
};
|
||||
|
||||
#endif //NALOGA0201_ARTWORK_H
|
7
semester_2/programiranje_2/naloga0401/Date.cpp
Normal file
7
semester_2/programiranje_2/naloga0401/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/naloga0401/Date.h
Normal file
19
semester_2/programiranje_2/naloga0401/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/naloga0401/Dimension.cpp
Normal file
9
semester_2/programiranje_2/naloga0401/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/naloga0401/Dimension.h
Normal file
18
semester_2/programiranje_2/naloga0401/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/naloga0401/Gallery.cpp
Normal file
20
semester_2/programiranje_2/naloga0401/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;
|
||||
}
|
26
semester_2/programiranje_2/naloga0401/Gallery.h
Normal file
26
semester_2/programiranje_2/naloga0401/Gallery.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef NALOGA0201_GALLERY_H
|
||||
#define NALOGA0201_GALLERY_H
|
||||
|
||||
#include "Artwork.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
|
||||
|
19
semester_2/programiranje_2/naloga0401/README.md
Normal file
19
semester_2/programiranje_2/naloga0401/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
Iz naloge 2.1 vzemite razred Artwork (datoteki Artwork.h in Artwork.cpp).
|
||||
Dodajte razred Date, ki naj ima:
|
||||
instančne spremenljivke day, month in year (vse tipa unsigned int),
|
||||
konstruktor s tremi parametri in
|
||||
metodo toString.
|
||||
Dodajte razred Artist, ki naj ima:
|
||||
instančne spremenljivke name (tipa string), biography (tipa string) in dateOfBirth (tipa Date),
|
||||
konstruktor s tremi parametri in
|
||||
metodo toString.
|
||||
V razredu Artwork dodajte instančno spremenljivko artist(tipa Artist*). Ustrezno popravite konstruktor in metode v razredu Artwork.
|
||||
Dodajte razred Gallery, ki naj ima:
|
||||
instančni spremenljivki name (string) in artworks (vector<Artwork*>).
|
||||
konstruktor z enim parametrom (samo name),
|
||||
metodo void addArtwork(Artwork* artwork), ki kot argument prejme kazalec na objekt tipa Artwork in ga doda v artworks,
|
||||
metodo printArtworks, ki izpiše vse umetnine, ki jih ima galerija,
|
||||
metodo toString.
|
||||
V glavnem programu zapišite oz. sestavite program, ki bo predstavljal eno galerijo z vsaj 5 umetninami.
|
||||
|
||||
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.).
|
30
semester_2/programiranje_2/naloga0401/naloga0401.cpp
Normal file
30
semester_2/programiranje_2/naloga0401/naloga0401.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#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);
|
||||
|
||||
slo.printArtworks();
|
||||
//std::cout << slo.toString();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user