Yurttas/PL/OOL/Cplusplus/F/04/02/03/01/Student.cpp

 1/*
 2   Copyright(C) 2002
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9  
10   date   : June 1, 2002.
11   authorĀ : Salih Yurttas.
12
13   Student.cpp
14*/
15
16#include "Student.h"
17
18Student::
19Student(const int a) {
20  last_name="";
21  m_i='\0';
22  first_name="";
23
24  number_of_courses = a;
25}
26
27Student::
28Student(const Student& a) {
29  last_name = a.Person::last_name;
30
31  m_i = a.Person::m_i;
32
33  first_name = a.Person::first_name;
34
35  number_of_courses = a.Courses::number_of_courses;
36
37  for(int i=0; i<number_of_courses; i++) {
38    course_name.push_back(a.Courses::course_name[i]);
39    grade.push_back(a.Courses::grade[i]);
40  }
41}
42
43ostream&
44operator<<(ostream& os,
45           const Student& a) {
46  string s_out;
47
48  s_out += a.Person::last_name;
49  s_out += " ";
50  s_out += a.Person::m_i;
51  s_out += " ";
52  s_out += a.Person::first_name;
53  s_out += " ";
54
55  if(s_out.length()<16)
56    s_out += "\t";
57
58  os << s_out;
59
60  if(s_out.length()<24)
61    os << "\t";
62
63  int n = a.Courses::number_of_courses;
64
65  for(int i=0; i<n; i++) {
66    os << ' ' << a.Courses::course_name[i];
67    os << ' ' << a.Courses::grade[i];
68  }
69  os << endl;
70
71  return os;
72}