consolidate all repos to one for archive
This commit is contained in:
24
semester_2/programiranje_2/primeri/Example24/Assistant.h
Normal file
24
semester_2/programiranje_2/primeri/Example24/Assistant.h
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef EXAMPLE24_ASSISTANT_H
|
||||
#define EXAMPLE24_ASSISTANT_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Assistant {
|
||||
protected:
|
||||
std::string name;
|
||||
std::string faculty;
|
||||
std::string subject;
|
||||
public:
|
||||
Assistant(std::string n, std::string f, std::string s) : name(n), faculty(f), subject(s) {
|
||||
}
|
||||
virtual ~Assistant() {
|
||||
}
|
||||
virtual void print() const {
|
||||
std::cout << "Assistant: " << name << " " << faculty << " " << subject << std::endl;
|
||||
}
|
||||
virtual std::string department() const {
|
||||
return faculty;
|
||||
}
|
||||
};
|
||||
#endif //EXAMPLE24_ASSISTANT_H
|
25
semester_2/programiranje_2/primeri/Example24/Student.h
Normal file
25
semester_2/programiranje_2/primeri/Example24/Student.h
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#ifndef EXAMPLE24_STUDENT_H
|
||||
#define EXAMPLE24_STUDENT_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Student {
|
||||
protected:
|
||||
std::string name;
|
||||
std::string faculty;
|
||||
double avgGrade;
|
||||
public:
|
||||
Student(std::string n, std::string f, double g) : name(n), faculty(f), avgGrade(g) {
|
||||
};
|
||||
virtual ~Student() {
|
||||
}
|
||||
virtual void print() const {
|
||||
std::cout << "Student: " << name << " " << faculty << " " << avgGrade << std::endl;
|
||||
}
|
||||
virtual std::string department() const {
|
||||
return faculty;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EXAMPLE24_STUDENT_H
|
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef EXAMPLE24_STUDENTASSISTANT_H
|
||||
#define EXAMPLE24_STUDENTASSISTANT_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class StudentAssistant : public Assistant, public Student {
|
||||
public:
|
||||
StudentAssistant(std::string n, std::string f1, double g, std::string f2, std::string s) :
|
||||
Assistant(n, f2, s), Student(n, f1, g) {
|
||||
}
|
||||
virtual ~StudentAssistant() {
|
||||
}
|
||||
void print() const {
|
||||
std::cout << "Student-Assistant: " << Student::name << " " << Student::faculty << " "
|
||||
<< avgGrade << " " << Assistant::faculty << " " << subject << std::endl;
|
||||
}
|
||||
};
|
||||
#endif //EXAMPLE24_STUDENTASSISTANT_H
|
34
semester_2/programiranje_2/primeri/Example24/main.cpp
Normal file
34
semester_2/programiranje_2/primeri/Example24/main.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
#include "Student.h"
|
||||
#include "Assistant.h"
|
||||
#include "StudentAssistant.h"
|
||||
|
||||
int main() {
|
||||
Student s1("Mark", "FERI", 8.3);
|
||||
Assistant a1("Mary", "FKKT", "Introduction to chemistry");
|
||||
StudentAssistant sa1("John", "FNM", 10, "FERI", "Discrete math");
|
||||
|
||||
s1.print();
|
||||
a1.print();
|
||||
sa1.print();
|
||||
/*
|
||||
std::cout << "--------------" << std::endl;
|
||||
Student* university[2];
|
||||
university[0]=&s1;
|
||||
university[1]=&sa1;
|
||||
//university[1]=&a1; // ERROR: class Assistant is not with any relation with class Student
|
||||
for (int i=0; i < 2; i++) {
|
||||
university[i]->print();
|
||||
std::cout << "Department: " << university[i]->department() << std::endl;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
std::cout << "--------------" << std::endl;
|
||||
sa1.print();
|
||||
//std::cout << "Department: " << sa1.department() << std::endl; // error
|
||||
std::cout << "Department Assistant: " << sa1.Assistant::department() << std::endl;
|
||||
std::cout << "Department Student: " << sa1.Student::department() << std::endl;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user