Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <cstdio>
- #include <time.h>
- #include <string.h>
- #include <iostream>
- using namespace std;
- class Date{
- private:
- int day;
- int month;
- int year;
- public:
- Date(){
- time_t t=time(NULL);
- struct tm* aTm = localtime(&t);
- day=aTm->tm_mday;
- month=aTm->tm_mon+1;
- year=aTm->tm_year+1900;
- }
- ~Date(){}
- Date(int d, int m, int y){
- day = d;
- month = m;
- year = y;
- }
- Date(const Date &d){
- day=d.day;
- month=d.month;
- year=d.year;
- }
- int getDay(){
- return day;
- }
- Date& setDay(int d){
- day = d;
- return *this;
- }
- int getMonth(){
- return month;
- }
- Date& setMonth(int m){
- month = m;
- return *this;
- }
- int getYear(){
- return year;
- }
- Date& setYear(int y){
- year = y;
- return *this;
- }
- void printDate(){
- printf("Date: %02d.%02d.%02d\n", day, month, year);
- }
- };
- enum Type {instrumental,vocal, stishok, proza};
- class Artist{
- private:
- char* name;
- char* surname;
- public:
- Artist(){
- name = "Null";
- surname = "Null";
- }
- Artist(char* n, char* m){
- name = new char[strlen(n)+1];
- surname = new char[strlen(m)+1];
- strcpy(name, n);
- strcpy(surname, m);
- }
- Artist(const Artist &a){
- name = new char[strlen(a.name)+1];
- surname = new char[strlen(a.surname)+1];
- strcpy(name, a.name);
- strcpy(surname, a.surname);
- }
- ~Artist(){}
- char* getName(){
- return name;
- }
- char* getSurname(){
- return surname;
- }
- Artist& setName(char* n){
- name = new char[strlen(n)+1];
- strcpy(name, n);
- cout << name << " " << n << endl;
- return *this;
- }
- Artist& setSurname(char* n){
- surname = new char[strlen(n)+1];
- strcpy(surname, n);
- return *this;
- }
- void printInfo(){
- cout << "Name: " << name << endl;
- cout << "Surname: " << surname << endl;
- }
- };
- class Scene{
- private:
- Type type;
- Artist* artist;
- int dur;
- char* title;
- public:
- Scene(){
- type = stishok;
- artist = new Artist();
- title = "Null";
- dur = 0;
- }
- Scene(Type ty, Artist* a, char* t, int d){
- type = ty;
- artist = a;
- title = new char[strlen(t)+1];
- strcpy(title, t);
- dur = d;
- }
- Scene(const Scene& sc){
- type = sc.type;
- artist = sc.artist;
- title = sc.title;
- dur = sc.dur;
- }
- ~Scene(){}
- void printInfo(){
- switch(type){
- case(instrumental):
- {
- cout << "Type: " << "Instrumental" << endl;
- break;
- }
- case(vocal):
- {
- cout << "Type: " << "Vocal" << endl;
- break;
- }
- case(stishok):
- {
- cout << "Type: " << "Stishok" << endl;
- break;
- }
- case(proza):
- {
- cout << "Type: " << "Proza" << endl;
- break;
- }
- }
- cout << "Title: " << title << endl;
- cout << "Artist info: " << endl;
- artist->printInfo();
- cout << "Duration: " << dur << endl;
- }
- char* getTitle(){
- return title;
- }
- Scene& setTitle(char* t){
- title = new char[strlen(t)+1];
- strcpy(title, t);
- return *this;
- }
- Type getType(){
- return type;
- }
- Scene& setType(Type t){
- type = t;
- return *this;
- }
- Artist* getArtist(){
- return artist;
- }
- Scene& setArtist(Artist* a){
- artist = a;
- return *this;
- }
- int getDur(){
- return dur;
- }
- Scene& setDur(int d){
- dur = d;
- return *this;
- }
- };
- class Concert{
- private:
- char* org;
- Date date;
- Scene* scenes;
- int cnt;
- public:
- Concert(){
- org = "Null";
- date = Date();
- cnt = 0;
- }
- Concert(char* o, Date& d, Scene* sc, int c){
- org = new char[strlen(o)+1];
- strcpy(org, o);
- date = Date(d);
- cnt = c;
- scenes = new Scene[cnt];
- for(int i=0; i<cnt; i++){
- scenes[i] = sc[i];
- }
- }
- Concert(Concert const &c){
- org = new char[strlen(c.org)+1];
- strcpy(org, c.org);
- date = c.date;
- cnt = c.cnt;
- scenes = new Scene[cnt];
- for(int i=0; i<cnt; i++){
- scenes[i] = c.scenes[i];
- }
- }
- ~Concert(){}
- char* getOrg(){
- return org;
- }
- Concert& setOrg(char* o){
- org = new char[strlen(o)+1];
- strcpy(org, o);
- return *this;
- }
- Date& getDate(){
- return date;
- }
- Concert& setDate(Date d){
- date = d;
- return *this;
- }
- Scene* getScenes(){
- return scenes;
- }
- Concert& setScenes(int c, Scene* sc){
- cnt = c;
- scenes = new Scene[cnt];
- for(int i=0; i<cnt; i++){
- scenes[i] = sc[i];
- }
- return *this;
- }
- int getCount(){
- return cnt;
- }
- Concert& addOne(const Scene& sc){
- Scene* newScenes = new Scene[cnt+1];
- for (int i=0; i<cnt; i++){
- newScenes[i] = scenes[i];
- }
- newScenes[cnt] = sc;
- cnt++;
- scenes = new Scene[cnt];
- for(int i=0; i<cnt; i++){
- scenes[i] = newScenes[i];
- }
- return *this;
- }
- void printInfo(){
- cout << "Org: " << org << endl;
- for (int i=0; i<cnt; i++){
- cout << "Scene " << i+1 << ":" << endl;
- scenes[i].printInfo();
- cout << endl;
- }
- cout << "Date: ";
- date.printDate();
- cout << "Count: " << cnt << endl;
- }
- void shortInfo(){
- cout << "Org: " << org << endl;
- for (int i=0; i<cnt; i++){
- cout << "Title:" << scenes[i].getTitle() << endl;
- cout << "Duration: " << scenes[i].getDur() << endl;
- cout << endl;
- }
- }
- };
- int main()
- {
- // cout << "<< Date example >>" << endl;
- Date d;
- // d.printDate();
- // cout << endl;
- // cout << "<< Artist example >>" << endl;
- Artist* a = new Artist("Vasya", "Pupkin");
- // a->printInfo();
- // cout << endl;
- // cout << "<< Scene example >>" << endl;
- Scene sc1(stishok, a, "Yeah1", 1);
- sc1.printInfo();
- // cout << endl;
- a->setName("Vasiok");
- // sc1.printInfo();
- // cout << endl;
- Scene sc2(proza, a, "Yeah2", 2);
- Scene sc3(stishok, a, "Yeah3", 3);
- Scene sc4(sc3);
- sc1.printInfo();
- Scene scs[3] = {sc1,sc2,sc3};
- cout << endl;
- cout << "<< Concert example >>" << endl;
- Concert* c = new Concert("Slava", d, scs, 3);
- c->printInfo();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement