Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Person{
- public:
- string name, birthDate;
- Person(string name, string date){
- this->name = name;
- this->birthDate = date;
- }
- void print(){
- cout << "Person: {Name: " << name << ", Birth Date: " << birthDate << "}";
- }
- };
- class Teacher : public Person{
- public:
- string category, classes[36];
- Teacher(string name, string date, string category, string classes[], int classesLength) : Person(name, date){
- this->category = category;
- if(classesLength <= 36) for(int i = 0; i < classesLength; i ++) this->classes[i] = classes[i];
- }
- void print(){
- cout << "Teacher: {Name: " << name << ", Birth Date: " << birthDate << ", Category: " << category << ", Classes: ";
- for(int i = 0; i < 36; i++){
- if(classes[i] == " ") break;
- else cout << classes[i] << " ";
- }
- cout << "}";
- }
- void next(){
- string newClasses[36];
- int index = 0;
- for(int i = 0; i < 36; i ++){
- string element = classes[i];
- int c = stoi(element.substr(0, element.length() - 1)) + 1;
- if(c < 11){
- newClasses[index] = to_string(c) + element.substr(element.length() - 1, 1);
- index++;
- }
- }
- for(int i = 0; i < index; i++) classes[i] = newClasses[i];
- }
- };
- class Pupil : public Person{
- public:
- string project, m_class;
- Pupil(string name, string date, string project, string theClass) : Person(name, date){
- this->project = project;
- this->m_class = theClass;
- }
- void print(){
- cout << "Pupil: {Name: " << name << ", Birth Date: " << birthDate << ", Class: " << m_class << ", Project: " << project << "}";
- }
- };
- int main(){
- string classes[5] = {"10A", "11A", "5B"};
- Teacher teacher = new Teacher("Teacher's Name", "10.10.2010", "Biology", classes, 5)
- }
Add Comment
Please, Sign In to add comment