Advertisement
Misipuk

Untitled

Dec 4th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.66 KB | None | 0 0
  1. #include <conio.h>
  2. #include <cstdio>
  3. #include <time.h>
  4. #include <string.h>
  5. #include <iostream>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. class Date{
  11. private:
  12. int day;
  13. int month;
  14. int year;
  15.  
  16. public:
  17. Date(){
  18. time_t t=time(NULL);
  19. struct tm* aTm = localtime(&t);
  20. day=aTm->tm_mday;
  21. month=aTm->tm_mon+1;
  22. year=aTm->tm_year+1900;
  23. }
  24.  
  25. ~Date(){}
  26.  
  27. Date(int d, int m, int y){
  28. day = d;
  29. month = m;
  30. year = y;
  31. }
  32.  
  33. Date(const Date &d){
  34. day=d.day;
  35. month=d.month;
  36. year=d.year;
  37. }
  38.  
  39. int getDay(){
  40. return day;
  41. }
  42.  
  43. Date& setDay(int d){
  44. day = d;
  45. return *this;
  46. }
  47.  
  48. int getMonth(){
  49. return month;
  50. }
  51.  
  52. Date& setMonth(int m){
  53. month = m;
  54. return *this;
  55. }
  56.  
  57. int getYear(){
  58. return year;
  59. }
  60.  
  61. Date& setYear(int y){
  62. year = y;
  63. return *this;
  64. }
  65.  
  66. void printDate(){
  67. printf("Date: %02d.%02d.%02d\n", day, month, year);
  68. }
  69. };
  70.  
  71. enum Type {instrumental,vocal, stishok, proza};
  72.  
  73. class Artist{
  74. private:
  75. char* name;
  76. char* surname;
  77. double c;
  78.  
  79. public:
  80. Artist(){
  81. name = "Null";
  82. surname = "Null";
  83. c = 1;
  84. }
  85.  
  86. Artist(char* n, char* m, double c1){
  87. name = new char[strlen(n)+1];
  88. surname = new char[strlen(m)+1];
  89. strcpy(name, n);
  90. strcpy(surname, m);
  91. c = c1;
  92. }
  93.  
  94. Artist(const Artist &a){
  95. name = new char[strlen(a.name)+1];
  96. surname = new char[strlen(a.surname)+1];
  97. strcpy(name, a.name);
  98. strcpy(surname, a.surname);
  99. c = a.c;
  100. }
  101.  
  102. ~Artist(){}
  103.  
  104. char* getName(){
  105. return name;
  106. }
  107.  
  108. char* getSurname(){
  109. return surname;
  110. }
  111.  
  112. double getC(){
  113. return c;
  114. }
  115.  
  116. Artist& setName(char* n){
  117. name = new char[strlen(n)+1];
  118. strcpy(name, n);
  119. cout << name << " " << n << endl;
  120. return *this;
  121. }
  122.  
  123. Artist& setSurname(char* n){
  124. surname = new char[strlen(n)+1];
  125. strcpy(surname, n);
  126. return *this;
  127. }
  128.  
  129. Artist& setC(double c1){
  130. c = c1;
  131. return *this;
  132. }
  133.  
  134. void printInfo(){
  135. cout << "Name: " << name << endl;
  136. cout << "Surname: " << surname << endl;
  137. cout << "Coef: " << c << endl;
  138. }
  139. };
  140.  
  141. class Scene{
  142. private:
  143. Type type;
  144. Artist* artist;
  145. int dur;
  146. char* title;
  147.  
  148. public:
  149. Scene(){
  150. type = stishok;
  151. artist = new Artist();
  152. title = "Null";
  153. dur = 0;
  154. }
  155.  
  156. Scene(Type ty, Artist* a, char* t, int d){
  157. type = ty;
  158. artist = a;
  159. title = new char[strlen(t)+1];
  160. strcpy(title, t);
  161. dur = d;
  162. }
  163.  
  164. Scene(const Scene& sc){
  165. type = sc.type;
  166. artist = sc.artist;
  167. title = sc.title;
  168. dur = sc.dur;
  169. }
  170.  
  171. ~Scene(){}
  172.  
  173. void printInfo(){
  174. switch(type){
  175. case(instrumental):
  176. {
  177. cout << "Type: " << "Instrumental" << endl;
  178. break;
  179. }
  180. case(vocal):
  181. {
  182. cout << "Type: " << "Vocal" << endl;
  183. break;
  184. }
  185. case(stishok):
  186. {
  187. cout << "Type: " << "Stishok" << endl;
  188. break;
  189. }
  190. case(proza):
  191. {
  192. cout << "Type: " << "Proza" << endl;
  193. break;
  194. }
  195. }
  196. cout << "Title: " << title << endl;
  197. cout << "Artist info: " << endl;
  198. artist->printInfo();
  199. cout << "Duration: " << dur << endl;
  200. }
  201.  
  202. char* getTitle(){
  203. return title;
  204. }
  205.  
  206. Scene& setTitle(char* t){
  207. title = new char[strlen(t)+1];
  208. strcpy(title, t);
  209. return *this;
  210. }
  211.  
  212. Type getType(){
  213. return type;
  214. }
  215.  
  216. Scene& setType(Type t){
  217. type = t;
  218. return *this;
  219. }
  220.  
  221. Artist* getArtist(){
  222. return artist;
  223. }
  224.  
  225. Scene& setArtist(Artist* a){
  226. artist = a;
  227. return *this;
  228. }
  229.  
  230. int getDur(){
  231. return dur;
  232. }
  233.  
  234. Scene& setDur(int d){
  235. dur = d;
  236. return *this;
  237. }
  238.  
  239. };
  240.  
  241. class Concert{
  242. private:
  243. char* org;
  244. Date date;
  245. Scene** scenes;
  246. int cnt;
  247. int price;
  248. public:
  249. Concert(){
  250. org = "Null";
  251. date = Date();
  252. cnt = 0;
  253. price = 0;
  254. }
  255.  
  256. Concert(char* o, Date &d, Scene** sc, int c){
  257. double maxC = 0;
  258. org = new char[strlen(o)+1];
  259. strcpy(org, o);
  260. date = Date(d);
  261. cnt = c;
  262. scenes = new Scene*[cnt];
  263. for(int i=0; i<cnt; i++){
  264. scenes[i] = sc[i];
  265. if(sc[i]->getArtist()->getC() > maxC){
  266. maxC = sc[i]->getArtist()->getC();
  267. }
  268. }
  269. price = maxC * 100 + 1;
  270. }
  271.  
  272. Concert(Concert const &c){
  273. org = new char[strlen(c.org)+1];
  274. strcpy(org, c.org);
  275. date = c.date;
  276. cnt = c.cnt;
  277. price = c.price;
  278. scenes = new Scene*[cnt];
  279. for(int i=0; i<cnt; i++){
  280. scenes[i] = c.scenes[i];
  281. }
  282. }
  283.  
  284. ~Concert(){}
  285.  
  286. char* getOrg(){
  287. return org;
  288. }
  289.  
  290. Concert& setOrg(char* o){
  291. org = new char[strlen(o)+1];
  292. strcpy(org, o);
  293. return *this;
  294. }
  295.  
  296. Date& getDate(){
  297. return date;
  298. }
  299.  
  300. Concert& setDate(Date d){
  301. date = d;
  302. return *this;
  303. }
  304.  
  305. Scene** getScenes(){
  306. return scenes;
  307. }
  308.  
  309. Concert& setScenes(int c, Scene** sc){
  310. cnt = c;
  311. scenes = new Scene*[cnt];
  312. for(int i=0; i<cnt; i++){
  313. scenes[i] = sc[i];
  314. }
  315. return *this;
  316. }
  317.  
  318. int getCount(){
  319. return cnt;
  320. }
  321.  
  322. double getPrice(){
  323. return price;
  324. }
  325.  
  326. Concert& addOne(Scene** sc){
  327. Scene** newScenes = new Scene*[cnt+1];
  328. for (int i=0; i<cnt; i++){
  329. newScenes[i] = scenes[i];
  330. }
  331. newScenes = sc;
  332. cnt++;
  333. scenes = new Scene*[cnt];
  334. for(int i=0; i<cnt; i++){
  335. scenes[i] = newScenes[i];
  336. }
  337. return *this;
  338. }
  339.  
  340. void printInfo(){
  341. cout << "Org: " << org << endl;
  342. for (int i=0; i<cnt; i++){
  343. cout << "Scene " << i+1 << ":" << endl;
  344. scenes[i]->printInfo();
  345. cout << endl;
  346. }
  347. cout << "Date: ";
  348. date.printDate();
  349. cout << "Count: " << cnt << endl;
  350. cout << "Price: " << price << endl;
  351. }
  352.  
  353. void shortInfo(){
  354. cout << "Org: " << org << endl;
  355. for (int i=0; i<cnt; i++){
  356. cout << "Title:" << scenes[i]->getTitle() << endl;
  357. cout << "Duration: " << scenes[i]->getDur() << endl;
  358. cout << endl;
  359. }
  360. }
  361.  
  362. };
  363.  
  364. int main()
  365. {
  366. Date d = Date();
  367. Artist* a = new Artist("Vasya", "Pupkin", 1.2);
  368. a->printInfo();
  369. cout << endl;
  370. Artist* b = new Artist("Vasiok", "Pupkin", 1.5);
  371. Artist* c = new Artist("Friend", "Pupkina", 1.7);
  372. Scene* sc1 = new Scene(stishok, a, "Vystuplenie", 1);
  373. Scene* sc2 = new Scene(stishok, b, "Vystuplenie", 1);
  374. Scene* sc3 = new Scene(stishok, c, "Vystuplenie", 1);
  375. Scene** scs = new Scene*[3];
  376. scs[0] = sc1;
  377. scs[1] = sc2;
  378. scs[2] = sc3;
  379. Concert* con = new Concert("Mashka", d, scs, 3);
  380.  
  381. con->printInfo();
  382. return 0;
  383. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement