Repository navigation
Expand file tree
/
Copy pathCourse.cc
More file actions
executable file
·95 lines (79 loc) · 1.92 KB
/
Copy pathCourse.cc
File metadata and controls
executable file
·95 lines (79 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <string>
#include <sstream>
#include "Course.h"
Course::Course(string s, string nu, string na, string i, int e)
{
subj = s;
num = nu;
name = na;
instr = i;
enrol = e;
books = new BookArray();
}
Course::~Course()
{
delete books;
}
string Course::getCode() { return subj + num; }
string Course::getName() { return name; }
string Course::getInstr() { return instr; }
int Course::getEnrol() { return enrol; }
BookArray* Course::getBookArray() {return books;}
bool Course::operator==(string& str)
{
return getCode() == str;
}
int Course::getNumBooks() { return books->getSize(); }
void Course::addBook(Book* b)
{
books->add(b);
}
void Course::BooksString(string& output)
{
if(getNumBooks() == 0)
{
output = "\nThis course has no textbook\n";
return;
}
for(int i = 0; i<getNumBooks(); i++)
{
int editionint = books->getBook(i)->getEdition();
int yearint = books->getBook(i)->getYear();
string edtion;
string year;
stringstream ss;
stringstream ff;
ss << editionint;
edtion = ss.str();
ff << yearint;
year = ff.str();
output += "\nTitle: " + books->getBook(i)->getTitle()
+ "\nAuthors: " + books->getBook(i)->getAuthors()
+ "\nISBN: " + books->getBook(i)->getISBN()
+ "\nEdition: " + edtion
+ "\nYear: " + year
+ "\n___________________________________";
}
}
string& operator+=(string& outStr, Course& course)
{
int enrolint = course.getEnrol();
int numBookint = course.getNumBooks();
string enrol;
string numBook;
stringstream ss;
stringstream ff;
ss << enrolint;
enrol = ss.str();
ff << numBookint;
numBook = ff.str();
string code = course.getCode();
string name = course.getName();
string instr = course.getInstr();
outStr += "Course code: " + code + "\nCourse name: "
+ name + "\nInstructor: " + instr + "\nEnrolment: "
+ enrol + "\nNumber of Textbooks: "
+ numBook + "\n\n";
//cout << "in course" + outStr << endl;
return outStr;
}